如何解决npm“UNMET PEER DEPENDENCY”

我有我的package.json文件的问题。

它应该正常工作,因为我使用其他项目中的大多数节点模块,但我有下面的package.json

 "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" } 

他们应该都运行良好,因为所有的依赖关系存在,因为angular度现在在rc.4和rxjs在5.0.0-beta.10。

但是我得到3个未满足的依赖关系

 npm install 'rxjs@5.0.0-beta.10' 'rxjs@5.0.0-beta.6' '@angular/core@2.0.0-rc.1' 

我也得到这些警告:

 npm WARN @angular/core@2.0.0-rc.4 requires a peer of rxjs@5.0.0-beta.6 but none was installed. npm WARN @angular/http@2.0.0-rc.1 requires a peer of rxjs@5.0.0-beta.6 but none was installed. npm WARN @angular/http@2.0.0-rc.1 requires a peer of @angular/core@2.0.0-rc.1 but none was installed. 

我也做了:

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

节点是最新版本,仍然是同样的问题…所以只是想知道是否有什么问题?

我认为这是因为依赖解决scheme有点破,请参阅https://github.com/isaacs/npm/issues/1341#issuecomment-20634338

您可能需要手动安装具有未满足依赖关系的顶级模块:

npm install findup-sync@0.1.2

或者构build你的package.json,这样任何顶级模块也是其他模块的依赖关系。

你的问题也可能是npm未能下载软件包,超时或什么都没有。 有时重新运行npm install补救措施。

您也可以使用npm install手动安装失败的软件包

在尝试npm安装之前可能会有帮助的其他步骤是:

使用以下命令删除node_modules:

rm -rf node_modules/

然后

npm cache clean

解释为什么有时需要删除node_modules:

显然,如果在npm安装期间嵌套的模块安装失败,后续的npm安装将不会检测到这些缺失的嵌套依赖关系。 如果是这样的话,有时只要删除那些缺less嵌套模块的顶层依赖就足够了,再次运行npm install。

请参阅https://github.com/npm/npm/issues/1336