NPM依赖项由依赖项共享 [英] NPM dependencies shared by dependencies

查看:265
本文介绍了NPM依赖项由依赖项共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在npm 3.3.12(节点4.2.2)上,发生以下事情:

On npm 3.3.12 (node 4.2.2), the following thing happen:

我运行 npm install 在项目中,我的项目中的一个依赖项也是另一个依赖项之一的依赖项。例如:

I run npm install in a project where one of the dependencies in my project is also a dependency of one of the other dependencies. For instance:


  • 我的项目取决于PackageA和PackageB

  • PackageA也取决于PackageB
  • 我的项目和PackageA都依赖于PackageB的相同版本

然后,我运行 npm更新。 NPM输出列表:

Then, I run npm update in my prroject. The NPM output lists:

PackageB@x.x.x node_modules/PackageB -> node_modules/PackageA/node_modules/PackageB

因此,突然之间PackageB不在我项目的node_modules中(仅在项目文件中PackageA)和require( PackageB)下的node_modules失败。

So then suddenly PackageB is not in node_modules of my project (only in node_modules under PackageA) and require("PackageB") in the files of the project fails.

是什么原因造成的,如何最好地避免此问题?

What is causing this, and how can I best avoid the issue?

推荐答案

这是一个错误,已在NPM 3.4.1中修复:

It was a bug, fixed in NPM 3.4.1:

https://github.com/npm/npm/issues/10446

这篇关于NPM依赖项由依赖项共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆