11

I'm working on a project using React. I've tried to install Bootstrap, but my project won't compile. I've installed [email protected] using npm. But I keep on getting the following error message:

./node_modules/bootstrap/dist/js/bootstrap.js
Module not found: Can't resolve 'jquery' in '/Users/my_name/React_Projects/my_react_project/node_modules/bootstrap/dist/js'

This is a project that I was given to work on, so I haven't made it from scratch -- so I'm just piecing things together as I go. I thought it may be an error with Webpack, so one of the things I tried to do was add jquery as an external resource in my webpack.config.js file -- but there is no such file in the project at this point.

This project was created using react-scripts, which I am told is a wrapper around Webpack. Anyone have any idea how to resolve this issue? How can I get jQuery to work so I can start using Bootstrap?

2
  • 1
    Read this: stackoverflow.com/questions/38015494/…. Use either resctstrap or react-bootstrap. I tried both and I think that reactstrap is better, easier to use, although the other one is more popular. Commented Mar 31, 2018 at 15:21
  • @Rahamin, that was very helpful and I ended up using reactstrap in my application! Commented Mar 31, 2018 at 18:12

3 Answers 3

27

You will need to install the jquery and popper.js packages from npm. In your terminal, run below command:

npm install jquery popper.js

or

yarn add jquery popper.js

Next, go to the src/index.js file and add the following imports:

import $ from 'jquery';
import Popper from 'popper.js';
import 'bootstrap/dist/js/bootstrap.bundle.min';

There you have it. You can now use the full power of Bootstrap and jQuery in your React application.

Sign up to request clarification or add additional context in comments.

1 Comment

really this is working to you????
1

You will need to install jquery package from npm. In your terminal, run below command:

npm install jquery --save

Comments

1

This post solved my issues, maybe it can help you guys out too. Just run these two commands.

npm install --save resolve-url-loader --only=dev
npm i --save-dev bootstrap@next bootstrap-loader tether jquery

Look here link

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.