Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

396
Visualizações
Reactjs & Express 'You may need an appropriate loader to handle this file type.'

I have created a React/Express server but when trying to import bootstrap I am getting the below:

Error

./node_modules/react-bootstrap/esm/Button.js
Module parse failed: Unexpected token (18:2)
You may need an appropriate loader to handle this file type.
|   active,
|   className,
|   ...props
| }, ref) => {
|   const prefix = useBootstrapPrefix(bsPrefix, 'btn');

Setup

enter image description here

App.js

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Customers from './components/customers';
import Button from 'react-bootstrap/Button';
import 'bootstrap/dist/css/bootstrap.min.css';

class App extends Component {
  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">React Express Starter</h1>
        </header>
        <Customers />
        <div>
          <div id="wallet-address"></div>
        </div>
      </div>
    );
  }
}

export default App;

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

I have webpack installed on both packages I am just completely lost as to why the issue is occurring. I have done the same without express with no issues but with both Express and React I can't seem to import any package without getting this same error.

Any help would be greatly appreciated.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

A typical React/Express development setup looks like this, assuming the React app's development server is running on port 3000 and Express on 5000...

  1. Proxy API requests for Express. In client/package.json add

     "proxy": "http://localhost:5000",
  2. Launch your Express app however you prefer to launch it

  3. Start your React app via npm start / yarn start in the app folder ( client in your case).

  4. Open your browser at http://localhost:3000

When installing client-side libraries such as react-bootstrap, make sure to install them in the client/package.json file.


A production build looks more like this

  1. Have Express statically serve files from your build directory and handle frontend paths

     // make sure this comes after any routes, preferably last const path = requires("path"); const clientBuild = path.join(__dirname, "client", "build"); app.use(express.static(clientBuild)); app.get("/*", (_req, res) => { res.sendFile(path.join(clientBuild, "index.html")); });
  2. Build your React app via npm run build / yarn build in the client folder.

  3. Start your Express application however you prefer to start it

  4. Open http://localhost:5000 in your browser.

Note that making changes to your React app in production mode requires a rebuild (step #2).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda