Missing peer dependencies
Asked Answered
B

3

34

I am new to npm and angular projects, and I am using [email protected] in my package.json. When I do npm install, I get the following error -

[email protected] requires a peer of [email protected] - 3 but none is installed. You must install peer dependencies yourself. 

Does this mean that I need to add [email protected] - 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?

Bifoliate answered 2/5, 2018 at 18:7 Comment(0)
C
53

Simply install the dependency yourself:

npm install [email protected] --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.

Cumine answered 2/5, 2018 at 21:36 Comment(3)
Isn't the whole point of npm to manage these dependencies lololol!?Credulous
I want npm to crash, burn and explodeReptile
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".Autoharp
D
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 [email protected] --save
Dodecagon answered 11/10, 2018 at 7:29 Comment(0)
C
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 "[email protected] - 3"

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

Cordwood answered 25/11, 2019 at 12:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.