score:183

Accepted answer

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)

score:1

if you have installed:
npm install jquery popper.js

instead:
global.jquery = require('jquery');
require('bootstrap');

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

look this

score:1

bootstrap 5 requires "popper.js core", you can run this instead:

npm install @popperjs/core --save

score:2

add the popper.js as dependency in your package.json file like this:

{
  "dependencies": {
    ...,
    "popper.js": "1.16.1",
    ...,
  }
}

and also add popper.js as required import before adding required bootstrap, as following:

require('popper.js');
require('bootstrap');

score:2

i also ran into the same issue and was installing popper using the following command :-

npm install vue-popperjs --save

but, then i realise i was using bootstrap 5, which no longer supports this command. so the command used with bootstrap 5 for "popperjs core",

npm install @popperjs/core --save

score:3

you can direct import like

import bootstrapbundle from './../path to node modules/../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js';

no need to install popper

score:4

like tomi0505 have written, you need to import bootstrap and other things like this:

import 'jquery';
import '@popperjs/core'; // edit here
import 'bootstrap/dist/js/bootstrap.bundle';

after that it will work fine, i hope.

score:5

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');

score:10

for bootstrap 5 you are to

npm users: npm install @popperjs/core --save

for yarn users: yarn add @popperjs/core

then import bootstrap like so:


import 'bootstrap/dist/js/bootstrap.bundle';


Related Query

More Query from same tag