Angular2 beta 11 'npm install' 警告 npm peerDependencies

Angular2 beta 11 'npm install' warnings npm peerDependencies

刚刚安装了 Angular2 beta 11 npm install angular2 --save 并收到以下警告:

d:\Projects\sample>npm install angular2 --save
sample@1.0.0 d:\Projects\sample
+-- angular2@2.0.0-beta.11
+-- UNMET PEER DEPENDENCY es6-promise@^3.0.2
+-- UNMET PEER DEPENDENCY es6-shim@^0.35.0
+-- UNMET PEER DEPENDENCY reflect-metadata@0.1.2
+-- UNMET PEER DEPENDENCY rxjs@5.0.0-beta.2
`-- UNMET PEER DEPENDENCY zone.js@^0.6.4

npm WARN angular2@2.0.0-beta.11 requires a peer of es6-promise@^3.0.2 but none was installed.
npm WARN angular2@2.0.0-beta.11 requires a peer of es6-shim@^0.35.0 but none was installed.
npm WARN angular2@2.0.0-beta.11 requires a peer of reflect-metadata@0.1.2 but none was installed.
npm WARN angular2@2.0.0-beta.11 requires a peer of rxjs@5.0.0-beta.2 but none was installed.
npm WARN angular2@2.0.0-beta.11 requires a peer of zone.js@^0.6.4 but none was installed.

以前的 Angular2 版本安装了依赖项 es6-promise es6-shim rxjs zone.js 到 main package.js 但现在不是。

"dependencies": {
    "angular2": "^2.0.0-beta.11"
  } 

我检查了 ..\node_modules\angular2\package.json 并且可以看到它依赖于这些包:

    "peerDependencies": {
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.35.0",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "^0.6.4"
  }, 

有什么想法吗?

这意味着 Angular2 需要这些依赖项(具有正确的版本)才能工作。您需要在项目依赖项中包含它们。

有关详细信息,请参阅此 link:

看来答案就在这里https://github.com/npm/npm/issues/6565

NPM 3 倍:

  1. peerDependencies will no longer be implicitly installed if they're not already a dependency or devDependency. This is the biggest change, and is the piece most likely to require developer intervention.
  2. Invalid or missing peerDependencies will be a warning instead of an error. This will mean that irregularities with peerDependencies will be left to developers to sort out, but peerDependency incompatibilities should be less painful for consumers, because installs will bail out due to dependency problems significantly less frequently.

在使用 npm install angular2 --save 失败后,我使用以下命令成功安装了 angular2:

npm install --save rxjs@5.0.0-beta.6 reflect-metadata@0.1.2 zone.js es6-shim angular2@2.0.0-beta.17

如果我们得到 UNMET PEER DEPENDENCY 那么 - 在清除 node_modules 文件夹并从 package.json 中删除依赖项之后 - 我们可以做两件事:

  • 安装较早版本的angular2
  • 手动安装缺少的依赖项