Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve npm "UNMET PEER DEPENDENCY"

I am having issues with my package.json file.

It should work fine as as I use most of the node modules in other projects, but I have this package.json below:

"dependencies": {
   "@angular/common": "^2.0.0-rc.1",
   "@angular/compiler": "^2.0.0-rc.1",
   "@angular/core": "^2.0.0-rc.1",
   "@angular/platform-browser": "^2.0.0-rc.1",
   "@angular/platform-browser-dynamic": "^2.0.0-rc.1",
   "@angular/router": "^2.0.0-rc.1",
   "angular2-in-memory-web-api": "0.0.7",
   "bootstrap": "^3.3.6",
   "es6-shim": "^0.35.0",
   "reflect-metadata": "^0.1.3",
   "rxjs": "^5.0.0-beta.6",
   "systemjs": "^0.19.27",
   "zone.js": "^0.6.12"
 },
  "devDependencies": {
    "body-parser": "^1.15.1",
    "express": "^4.13.4",
    "jsonwebtoken": "^6.2.0",
    "mongoose": "^4.4.15"
  }

and they should all run fine as all dependencies exist as angular is now in rc.4 and rxjs is on 5.0.0-beta.10.

But I get 3 unmet dependencies on

npm install
'[email protected]'
'[email protected]'
'@angular/[email protected]'  


I get these warnings too:

npm WARN @angular/[email protected] requires a peer of [email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of [email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.  


I have also done:

npm cache clean
npm update registry > with the registry link
npm update -g


node is on latest version and still same issue... so just wondering if there is something wrong?

like image 552
Jake Groves Avatar asked Jul 12 '16 21:07

Jake Groves


People also ask

Why does NPM no longer install peer dependencies?

See also Why do peer dependencies exist? npm no longer installs peer dependencies so you need to install them manually, just do an npm install on the needed deps, and then try to install the main one again.

How to resolve the unmet dependency problem?

you can resolve by installing the UNMET dependencies globally. install each one by one. its worked for me. Is this really the best solution, thought? Installing globally to ignore the actual "problem" for project dependencies?

What to do if NPM module is missing from install?

If that's the case, sometimes it's sufficient to remove the top-level dependency of those missing nested modules, and running npm install again. Thanks for contributing an answer to Stack Overflow!

Where can I find the list of peer dependencies?

Peer Dependencies are listed in the package.json file in the peerDependencies object. To get the most out of this article you should have at least an introductory understanding of npm.


1 Answers

I think its because the dependency resolution is a bit broken, see https://github.com/isaacs/npm/issues/1341#issuecomment-20634338

You may need to manually install top-level modules that have unmet dependencies:

npm install [email protected]

Or structure your package.json such that any top-level modules that are also dependencies of other modules are listed lower down.

Your problem could also be that npm failed to download the package, timed-out or whatnot. Sometimes re-running npm install remedies it.

You can also install the failed packages manually as well using npm install

Other steps that may help before attempting npm install again are:

Removing node_modules using:

rm -rf node_modules/

then

npm cache clean

To explain why removing node_modules sometimes is necessary:

Apparently if a nested module fails to install during npm install, subsequent npm install won't detect those missing nested dependencies. If that's the case, sometimes it's sufficient to remove the top-level dependency of those missing nested modules, and running npm install again.

See https://github.com/npm/npm/issues/1336

like image 119
Sir Mbuki Avatar answered Oct 21 '22 03:10

Sir Mbuki