I'm using Angular 5.2.0 together with Bootstrap 4 in my web project. I installed bootstrap 4 via npm i bootstrap --save
and it told me about unmet peer dependencies:
npm WARN [email protected] requires a peer of jquery@>=3.0.0 but none was installed.
npm WARN [email protected] requires a peer of popper.js@^1.11.0 but none was installed.
Of course, Bootstrap's JS relies on these peer dependencies. So far, so usual.
The thing is: I don't use any of Bootstraps JS. I'm using ng-bootstrap which are the Bootstrap Components rewritten for Angular.
This warning annoys me, because it really isn't a thing, when I'm not using it anyway (and nobody else in this project should - getting an error when trying to use Bootstrap's components natively is perfectly fine). Clean code and dependencies should not output any warnings.
To get rid of this warning, I tried different :
bootstrap
package.package.json
which are not used - and should (imho) also be avoided in a Clean Code environment.So: Is there any way to handle these peer dependency warnings in a clean manner?
UNMET PEER DEPENDENCY error is thrown when the dependencies of one or more modules specified in the package. json file is not met. Check the warnings carefully and update the package. json file with correct versions of dependencies. Then run rm -rf node_modules/ npm cache clean npm install.
Solution 1: Ignore the peerDependencies The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.
CLI command to install npm peerDependencies. This can be useful when developing modules. If you run this npm-install-peers command, moment will be installed because it's a direct peer dependency of your project.
Peer Dependencies are used to specify that our package is compatible with a specific version of an npm package. Good examples are Angular and React. To add a Peer Dependency you actually need to manually modify your package.json file.
Sadly, the real answer is that we need to just ignore the warnings.
The creator of ng-bootstrap
explicitly states that the warnings are our only option due to technical reasons in this answer. They also mention that you shouldn't install the jquery
or popper.js
dependencies due to potential conflicts (per the setup docs).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With