加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 00:50:07 所属栏目:百科 来源:网络整理
导读:我刚刚升级到 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
我刚刚升级到 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读