Jake Groves
Jake Groves

Reputation: 327

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?

Upvotes: 7

Views: 17619

Answers (1)

Sir Mbuki
Sir Mbuki

Reputation: 1210

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

Upvotes: 3

Related Questions