Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix this error : " Module not found :can't resolve popper.js "

After import the Bootstrap and Jquery this error is showning when compiling.

import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import 'bootstrap/dist/css/bootstrap.css'; import './index.css';  global.jQuery = require('jquery'); require('bootstrap'); 
like image 988
Ranindu Avatar asked Aug 12 '19 10:08

Ranindu


People also ask

Do I need Popper js?

Popper. js is required IF you're using Bootstrap JS. It's not required if you're using only the Bootstrap CSS.


2 Answers

Popper.js is a dependency of Bootstrap 4 which is used for showing popups. It is a peer dependency of bootstrap meaning it is something that bootstrap requires but doesn't include with itself when installed. So to install popper.js run

npm install popper.js --save 

It is setup as a peer dependency because some people just use the css of Bootstrap without the javascript. jQuery and popper.js are the peer dependencies which needs to be installed separately. If you require the javascript of Bootstrap you need to install jQuery and popper.js alongside Bootstrap 4.


Bootstrap 5 requires "Popper.js Core", not Popper.js. You should run this instead:

npm install @popperjs/core --save 

(thanks @Kyouma for adding this in the comments)

like image 68
acesmndr Avatar answered Sep 20 '22 20:09

acesmndr


It's simple you can Visit this, And save the file as popper.min.js

then import it.

import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import 'bootstrap/dist/css/bootstrap.css'; import './index.css'; import 'bootstrap/dist/js/popper.min.js'; global.jQuery = require('jquery'); require('bootstrap'); 
like image 39
Ayemun Hossain Ashik Avatar answered Sep 19 '22 20:09

Ayemun Hossain Ashik