每次尝试使用npm安装角度库(例如,我需要此库:https://www.npmjs.com/package/ngx-pinch-zoom)时,都会收到警告,提示我应该自己安装对等依赖项。
npm WARN @progress/kendo-theme-bootstrap@2.6.2 requires a peer of bootstrap@git://github.com/twbs/bootstrap.git#95f37e4c402df37db16781995ffa1592032df9c8 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-pinch-zoom@1.2.0 requires a peer of @angular/common@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-pinch-zoom@1.2.0 requires a peer of @angular/core@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
我试图将npm降级到小于3的版本,但是我得到了同样的东西: npm安装npm@2.8.4
Testing binary
Binary is fine
npm WARN @progress/kendo-theme-bootstrap@2.6.2 requires a peer of bootstrap@git://github.com/twbs/bootstrap.git#95f37e4c402df37db16781995ffa1592032df9c8 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ npm@2.8.4
added 469 packages from 498 contributors, removed 230 packages, updated 29 packages and audited 5980 packages in 62.539s
found 226 vulnerabilities (66 low, 106 moderate, 51 high, 3 critical)
run `npm audit fix` to fix them, or `npm audit` for details
npm -v 6.5.0
然后,该版本仍为6.5.0。有什么解决方案?
答案 0 :(得分:1)
npm 3明确删除了对等依赖项的自动安装,因为它引起的问题比它尝试解决的更多。例如,您可以在此处阅读有关内容:
https://blog.npmjs.org/post/110924823920/npm-weekly-5
https://github.com/npm/npm/releases/tag/v3.0.0
因此,不能,npm 3或更高版本不能自动安装对等依赖项。
您可以使用项目npm-install-peers
检测并安装对等项。要使用此运行npm install -g npm-install-peers
,然后在项目目录中运行npm-install-peers
。这将读出您的package.json
文件并安装所有peerDependencies
。
从v1.0.1开始,它不支持自动写回package.json,这从本质上解决了我们的需求。
您也可以尝试npm cache clean --f
,npm install
来解决问题。