Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

393
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!