Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM WARN: [email protected] requires a peer of popper.js

I have follow dependency part in package.json:

"dependencies": {
    "bootstrap": "*",
    "bootstrap-datepicker": "^1.7.1",
    "bower": "^1.8.2",
    "chosen-js": "^1.8.2",
    "datatables.net-dt": "^1.10.16",
    "jQuery-QueryBuilder": "^2.4.5",
    "jquery": "^1.4",
    "jquery-tagit": "*",
    "jquery-ui-dist": "^1.12.1",
    "prismjs": "^1.8.1",
    "qtip2": "^3.0.3",
    "multi-step-modal": 
        "git+ssh://[email protected]:2022/dependencies/multi-step-modal.git"
}

When I run npm update, I get:

[email protected] /home/opshenichnikova/NetBeansProjects/lps/public
├── [email protected] 
├── [email protected] 
├── [email protected]  (git+ssh://[email protected]:2022/dependencies/multi-step-modal.git#2f9bc29093c9939c2ba23fa18fd22001a74040d2)
├── UNMET PEER DEPENDENCY popper.js@^1.12.9
└── [email protected] 

npm WARN [email protected] requires a peer of popper.js@^1.12.9 but none was installed.

I searched for the reason and found just this: Bootstrap 4: Uncaught ReferenceError: Popper is not defined

I know that it is just warning, but I always keep my code warning-free.

like image 689
Olga Pshenichnikova Avatar asked Mar 13 '18 12:03

Olga Pshenichnikova


People also ask

Does bootstrap 4 require Popper js?

Though Popper. js is stated as required for Bootstrap 4, and Bootstrap 4 JS logs an error if it can't find Popper, you can still use Bootstrap 4 JS without Popper, if you don't need tooltips, popovers, dropdowns, nor modals.

Do I need to install popper for bootstrap?

Bootstrap depends on Popper, which is specified in the peerDependencies property. This means that you will have to make sure to add both of them to your package.


2 Answers

Popper.js is not really necessary

Bootstrap 4.0.0 release contains 2 new files bootstrap.bundle.js and bootstrap.bundle.min.js which contain Popper.js inside and you really do not need it.

bootstrap.bundle.min.js is exactly Bootstrap.js + Popper.js.

In Bootstrap v4.0.0 documentation it is still mentioned that you need the file for some components

Components requiring JavaScript

  • Dropdowns for displaying and positioning (also requires Popper.js)
  • Tooltips and popovers for displaying and positioning (also requires Popper.js)

I have not tested it but I think it is not necessary

Solutions

You can use the NPM path 'bootstrap/dist/js/bootstrap.bundle.js'.

Or if you finally want to download Popper.js, download the version you need.

bootstrap/package.json

  • Bootstrap v4.0.0 "popper.js": "^1.12.9"

  • Bootstrap v4.1.1 "popper.js": "^1.14.1"

like image 75
Enmanuel Avatar answered Oct 17 '22 20:10

Enmanuel


Bootstrap 4.0.0 requires popper, so just add "popper.js": "^1.12.9" to the package.json

For example dropdown, tooltips and popovers won't work: enter image description here

https://www.codeply.com/go/CuOfa7UnUA (broken w/o popper)

Note: As of 4.1, popper.js is only required for dropdowns, tooltips and popovers.

like image 12
Zim Avatar answered Oct 17 '22 19:10

Zim