For example, when I install Angular2:
例如,当我安装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.
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.
是否有一个神奇的标志,我可以传递给npm,它也将安装对等的依赖关系?我还没找到……手工复制和粘贴对等依赖项并确保我有正确的版本是很麻烦的。
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
What is the better way?
更好的方法是什么?
3 个解决方案
#1
90
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:
npm 3显式地删除了对等依赖项的自动安装,因为它导致的问题比它试图解决的问题要多。你可以在这里读到,例如:
http://blog.npmjs.org/post/110924823920/npm-weekly-5 https://github.com/npm/npm/releases/tag/v3.0.0
http://blog.npmjs.org/post/110924823920/npm-weekly-5 https://github.com/npm/npm/releases/tag/v3.0.0
So no, for the reasons given, you cannot install them automatically with npm 3 upwards.
因此,不,由于已知的原因,你不能在npm 3上自动安装它们。
#2
17
I solved it by rewriting package.json with the exact values warnings were about:
我通过重写包来解决它。带有确切值警告的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",
包中。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",
包中。json:“reflect-metadata”:“0.1.2”,
Delete node_modules directory
npm install
#3
10
The project npm-install-peers
will detect peers and install them.
项目npm-install-peer将检测并安装它们。
As of v1.0.1
it doesn't support writing back to the package.json
automatically, which would essentially solve our need here.
从v1.0.1开始,它不支持回写包。json是自动的,这基本上解决了我们这里的需求。
Please add your support to issue in flight: https://github.com/spatie/npm-install-peers/issues/4
请添加您的支持,以发布在航班:https://github.com/spatie/npm-install-peers/issues/4
#1
90
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:
npm 3显式地删除了对等依赖项的自动安装,因为它导致的问题比它试图解决的问题要多。你可以在这里读到,例如:
http://blog.npmjs.org/post/110924823920/npm-weekly-5 https://github.com/npm/npm/releases/tag/v3.0.0
http://blog.npmjs.org/post/110924823920/npm-weekly-5 https://github.com/npm/npm/releases/tag/v3.0.0
So no, for the reasons given, you cannot install them automatically with npm 3 upwards.
因此,不,由于已知的原因,你不能在npm 3上自动安装它们。
#2
17
I solved it by rewriting package.json with the exact values warnings were about:
我通过重写包来解决它。带有确切值警告的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",
包中。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",
包中。json:“reflect-metadata”:“0.1.2”,
Delete node_modules directory
npm install
#3
10
The project npm-install-peers
will detect peers and install them.
项目npm-install-peer将检测并安装它们。
As of v1.0.1
it doesn't support writing back to the package.json
automatically, which would essentially solve our need here.
从v1.0.1开始,它不支持回写包。json是自动的,这基本上解决了我们这里的需求。
Please add your support to issue in flight: https://github.com/spatie/npm-install-peers/issues/4
请添加您的支持,以发布在航班:https://github.com/spatie/npm-install-peers/issues/4