角度库安装对等依赖问题

问题描述 投票:1回答:1

每次我尝试使用npm安装角度库时(例如我需要这个库:https://www.npmjs.com/package/ngx-pinch-zoom),我会收到一些警告,说我应该自己安装对等依赖项。

 npm WARN @progress/[email protected] requires a peer of bootstrap@git://github.com/twbs/bootstrap.git#95f37e4c402df37db16781995ffa1592032df9c8 but none is installed. You must install peer dependencies yourself.
    npm WARN [email protected] 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 [email protected] 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: [email protected] (node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

我试图将npm降级到小于3的版本,但我得到同样的结果:npm install [email protected]

Testing binary
Binary is fine
npm WARN @progress/[email protected] 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: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
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。可能是什么解决方案?

angular typescript dependencies peer
1个回答
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 --fnpm install,看看它是否能解决您的问题。

© www.soinside.com 2019 - 2024. All rights reserved.