Missing peer dependencies

心已入冬 提交于 2020-12-28 12:24:05

问题


I am new to npm and angular projects, and I am using bootstrap@4.1.1 in my package.json. When I do npm install, I get the following error -

bootstrap@4.1.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself. 

Does this mean that I need to add jquery@1.9.1 - 3 to my package.json under peerDependencies section, apart from installing it locally with no-save option?

Also, do we need to install this missing peer dependency on the build server as well? Or can it be ignored?


回答1:


Simply install the dependency yourself:

npm install jquery@1.9.1 --save

Although --save is optional I recommend to put it, so the next time you simply can type only npm install and both bootstrap and jquery will be installed. You can read about peer dependencies on npm documentation.




回答2:


You should read the terminal whether all important dependencies have been installed. If it hasn't install those manually.

npm install <MISSING DEPENDANCY> --save

In your case

npm install jquery@1.9.1 --save



回答3:


In addition to the given answers:
If npm warns you about a missing dependency with a version range like 1.9.1 - 3 then you should definitely use that range to manually install the dependency – and not only its lower boundary. Use quotes for the range to work as a parameter in the install command. Both of the following examples will work:

npm install jquery@"1.9.1 - 3"
npm install "jquery@1.9.1 - 3"

Also the parameter --save can be omitted as of npm v5.0. This is the default now when you install.



来源:https://stackoverflow.com/questions/50140966/missing-peer-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!