简体   繁体   English

NPM-依赖项需要多个版本的软件包,但仅安装了一个版本

[英]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.

相关问题 找到一个安装的版本 npm package - Find the version of an installed npm package 如何通过使用npm install或yarn安装仅具有自己版本的package.json依赖项 - how to install only package.json dependencies with their own versions by using npm install or yarn 如何找到由NPM软件包的某个依赖项安装的二进制文件,以便可以执行它? - How do I locate a binary installed by one of my NPM package's dependencies so I can execute it? 如果全局安装 npm 包,如何在本地包中插入依赖项 - How to insert dependencies in local package if npm package is installed globally NPM在我们的依赖项package.json中锁定依赖项版本 - NPM Lock down dependency versions in our dependencies package.json 使用NPM安装软件包时,您能告诉它使用其依赖项之一的不同版本吗? - When installing a package with NPM, can you tell it to use a different version of one of its dependencies? npm依赖缠结的网络-我的库要求的软件包版本不同于我的依赖项使用的版本 - npm dependency tangled web - my library requires a different version of a package than one of my dependencies uses 需要在npm init上的package.json中全局安装依赖项 - Need globally installed dependencies in package.json on npm init 使用nvm,是否可以拥有一个版本的Node.js和多个版本的npm? - Using nvm, is it possible to have one version of Node.js and multiple versions of npm? 在需要版本冲突的项目中如何正确解决NPM依赖? - How do you properly resolve NPM dependencies in projects that require conflicting versions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM