【问题标题】:How to solve npm "UNMET PEER DEPENDENCY"如何解决 npm “未满足的对等依赖”
【发布时间】:2017-12-07 16:47:38
【问题描述】:

我的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


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

【问题讨论】:

  • 删除一切,先安装rxjs,再安装其他包
  • @MedetTleukabiluly 我会尽快尝试,谢谢

标签: node.js angular npm


【解决方案1】:

我认为是因为依赖解析有点破,见https://github.com/isaacs/npm/issues/1341#issuecomment-20634338

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

npm install findup-sync@0.1.2

或者构建你的 package.json 使得任何顶级模块同时也是其他模块的依赖项列在下方。

您的问题也可能是 npm 下载包失败、超时等。有时重新运行npm install 会对其进行补救。

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

在再次尝试 npm install 之前可能有帮助的其他步骤是:

删除 node_modules 使用:

rm -rf node_modules/

然后

npm cache clean

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

显然,如果嵌套模块在 npm install 期间安装失败,后续 npm install 将不会检测到那些缺少的嵌套依赖项。如果是这种情况,有时删除那些缺少的嵌套模块的顶级依赖项并再次运行 npm install 就足够了。

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

【讨论】:

    猜你喜欢
    • 2016-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-12
    • 2018-02-26
    • 2018-01-21
    • 1970-01-01
    • 2019-09-12
    相关资源
    最近更新 更多