[英]NPM - dependencies require package in multiple versions, but only one version is installed
After npm install
on clean environment, I get following problem with b
package: 在干净的环境上
npm install
后,我得到以下b
包问题:
npm ls b
a@2.0.6
├── b@3.0.0
├─┬ c@3.0.1
│ └── UNMET DEPENDENCY b@^1.0.0
└─┬ d@4.1.1
└─┬ c@2.1.0
└── UNMET DEPENDENCY b@^1.0.0
npm ERR! missing: b@^1.0.0, required by c@3.0.1
npm ERR! missing: b@^1.0.0, required by c@2.1.0
This obviously causes errors, as package c
needs b@^1.0.0
, but receives b@3.0.0
. 这显然会导致错误,因为程序包
c
需要b@^1.0.0
,但接收到b@3.0.0
。
I struggled to force npm to install both versions as if they were different packages. 我努力迫使npm安装两个版本,就好像它们是不同的软件包一样。 Tried going through npm docs, package-locks, and shinkwrap, but with no success.
尝试通过npm docs,package-locks和shinkwrap,但没有成功。 How can I solve this problem?
我怎么解决这个问题?
Environment info: 环境信息:
OS: macOS High Sierra 10.13.4
npm: 6.10
node: v8.8.1
Playing around I noticed, that a lot of packages had UNMET DEPENDENCY. 我注意到,很多程序包都有UNMET DEPENDENCY。 Following procedure fixed the problem:
以下过程解决了该问题:
rm -rf node_modules
npm cache clean --force
npm install
After cleaning npm cache the issue is completely resolved: 清理npm缓存后,问题已完全解决:
a@2.0.6
├── b@3.0.0
├─┬ c@3.0.1
│ └── b@^1.0.0
└─┬ d@4.1.1
└─┬ c@2.1.0
└── b@^1.0.0
Strange bug. 奇怪的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.