模块 – 如何强制npm 3安装嵌套依赖关系?

我刚刚升级npm version 3,注意到其中最大的变化之一是它执行了 flat dependency tree.

Your dependencies will Now be installed maximally flat. Insofar as is possible,all of your dependencies,and their dependencies,and THEIR dependencies will be installed in your project’s node_modules folder with no nesting. You’ll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.

所以例如如果软件包A依赖于软件包B,当你安装npm时你会得到这个文件结构:

--- root/
 |--- node_modules/
   |--- A/
   |--- B/

而不是版本2或更低版本的旧文件结构:

--- root/
 |--- node_modules/
   |--- A/
     |--- node_modules/
       |--- B/

一个(我肯定不是最后一个)我遇到的问题是这样的:

软件包A不知道npm v3的行为,并且取决于软件包B.但是,A假定旧(v2)文件结构,因为它的代码中具有node_modules / B,而不是正确的../node_modules/B.现在来自A的代码不会编译,因为它正在找错误的目录中的B /.

如果我不想让开发人员修改代码并等待A的更新,我想知道是否有一种方法可以设置一个选项,这将强制npm将A的依赖项安装在自己的node_modules文件夹中,同样的方式npm v2将会做到这一点.

您是否尝试过 – 安装npm安装捆绑?

https://docs.npmjs.com/cli/install

The –legacy-bundling argument will cause npm to install the package such that versions of npm prior to 1.4,such as the one included with node 0.8,can install the package. This eliminates all automatic deduping.

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...