34

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?

dev27
  • 605
  • 1
  • 7
  • 15

3 Answers3

53

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.

4ndt3s
  • 3,238
  • 2
  • 20
  • 30
  • 23
    Isn't the whole point of npm to manage these dependencies lololol!? – user875234 Jan 17 '19 at 13:55
  • 5
    I want npm to crash, burn and explode – Pitto Apr 24 '19 at 08:19
  • in automated environment this is (virtually) not possible. the peerDep version may change and manually assigned one will be useless. In Docker I would need to write a script that reads npm i output and parses it for all missed peeDeps in order to determine what to install "manually". – Spown Feb 23 '22 at 02:01
3

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
1

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.

Jpsy
  • 20,077
  • 7
  • 118
  • 115