如何自动安装npm对等项依赖关系?

如何自动安装npm对等项依赖关系?

问题描述:

例如,当我安装Angular2时:

For example, when I install 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的魔术标记也可以安装对等项依赖关系?我找不到一个...手动复制并粘贴对等项依赖关系并确保我具有正确的版本是很麻烦的.

Is there a magic flag that I can pass to npm that will install the peer dependencies as well? I haven't been able to find one... It's tedious to manually copy and paste the peer dependencies and make sure I have the correct versions.

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

In other words, I'd rather not have to do:

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明确删除了对等依赖项的自动安装,因为它引起的问题比它尝试解决的更多.例如,您可以在此处阅读有关内容:

The automatic install of peer dependencies was explicitly removed with npm 3, as it cause more problems than it tried to solve. You can read about it here for example:

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

因此,由于给定的原因,您不能使用npm 3或更高版本自动安装它们.

So no, for the reasons given, you cannot install them automatically with npm 3 upwards.