如何自动安装npm peer dependencies?

例如,当我安装Angular2时:

npm install --save angular2 temp@1.0.0 /Users/doug/Projects/dougludlow/temp ├── angular2@2.0.0-beta.3 ├── UNMET PEER DEPENDENCY es6-promise@^3.0.2 ├── UNMET PEER DEPENDENCY es6-shim@^0.33.3 ├── UNMET PEER DEPENDENCY reflect-metadata@0.1.2 ├── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.0 └── UNMET PEER DEPENDENCY zone.js@0.5.11 npm WARN angular2@2.0.0-beta.3 requires a peer of es6-promise@^3.0.2 but none was installed. npm WARN angular2@2.0.0-beta.3 requires a peer of es6-shim@^0.33.3 but none was installed. npm WARN angular2@2.0.0-beta.3 requires a peer of reflect-metadata@0.1.2 but none was installed. npm WARN angular2@2.0.0-beta.3 requires a peer of rxjs@5.0.0-beta.0 but none was installed. npm WARN angular2@2.0.0-beta.3 requires a peer of zone.js@0.5.11 but none was installed. 

是否有一个神奇的标志,我可以传递给npm将安装对等的依赖关系? 我一直无法find一个…手动复制和粘贴对等体的依赖关系,并确保我有正确的版本是繁琐的。

换句话说,我宁愿不必这样做:

 npm install --save angular2@2.0.0-beta.3 es6-promise@^3.0.2 es6-shim@^0.33.3 reflect-metadata@0.1.2 rxjs@5.0.0-beta.0 zone.js@0.5.11 

什么是更好的方法?

npm 3明确地删除了对等关系的自动安装,因为它导致了比试图解决的更多的问题。 你可以在这里阅读关于它的例子:

http://blog.npmjs.org/post/110924823920/npm-weekly-5 https://github.com/npm/npm/releases/tag/v3.0.0

所以不行,因为给出的原因,你不能自动安装npm 3以上。

我通过重写package.json来解决这个问题,警告的准确值是:

 npm WARN angular2@2.0.0-beta.3 requires a peer of es6-shim@^0.33.3 but none was installed. 

package.json:“es6-shim”:“^ 0.33.3”,

 npm WARN angular2@2.0.0-beta.3 requires a peer of reflect-metadata@0.1.2 

package.json:“reflect-metadata”:“0.1.2”,

 Delete node_modules directory npm install 

项目npm-install-peers将检测对等并安装它们。

v1.0.1它不支持自动回写package.json ,这在本质上解决了我们的需求。

请添加您的支持以在飞行中发布: https : //github.com/spatie/npm-install-peers/issues/4