node.js - npm "UNMET PEER DEPENDENCY"如何解决

标签 node.js angular npm

我的 package.json 文件有问题。

它应该工作正常,因为我在其他项目中使用了大部分 Node 模块,但我在下面有这个 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


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

最佳答案

我认为这是因为依赖项解析有点损坏,请参阅 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 缓存清理

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

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

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

关于node.js - npm "UNMET PEER DEPENDENCY"如何解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38339031/

相关文章:

node.js - 如何从 socket-io-redis 获取 redis 存储客户端?

javascript - 错误 : 'app-header' is not a known element: Angular 2

node.js - 如何将 Node 模块安装在与node_modules不同的文件夹下?

node.js - npm run dev "commands don' t 在 Windows 上工作

node.js - 如何在 Mongoose 模式中共享枚举值?

node.js - Mongodb更新查询删除除命令中指定字段之外的所有数组字段

Angular 9 - 如何将动态参数注入(inject)服务构造函数

javascript - 在 Angular 12 中过滤 NavigationEnd 事件?

Firebase 导入未在构造函数 ionic Native 中初始化

javascript - 找不到 npm 模块