简体   繁体   English

防止在node_modules中作用域化的node_modules

[英]prevent scoped node_modules within node_modules

When I use npm install, there are certain node packages that gets installed that contains nested node modules. 当我使用npm install时,会安装某些包含嵌套节点模块的节点程序包。

Like this: 像这样:

-node_modules
    -packageA
        +js
        -node_modules     <--- needs to be removed/ignored
             +jquery
    -packageA-sub1
        +js
        -node_modules     <--- needs to be removed/ignored
             +jquery

Is there a way to specify which packages not to include a nested scoped node_module? 有没有一种方法可以指定哪些软件包不包含嵌套作用域的node_module?

In my case, there are packages that are including jquery (packageA and packageA-sub1, sub2, sub3, sub4, etc), and it's messing up my website because I already include jquery in a few of my plugins. 在我的情况下,有一些包含jquery的软件包(packageA和packageA-sub1,sub2,sub3,sub4等),这弄乱了我的网站,因为我已经在一些插件中包含了jquery。 The only way to remedy this is by manually deleting the node_module folder inside the packageA folder. 解决此问题的唯一方法是手动删除packageA文件夹内的node_module文件夹。

I tried .npmignore but that doesn't seem to work: 我尝试了.npmignore,但这似乎不起作用:

packageA/node_modules/
packageA/node_modules
/packageA/node_modules
/packageA/node_modules/

I'm using npm 5.8 我正在使用npm 5.8

You can flatten the node_modules hierarchy, when modules share dependencies with the same version, using npm dedupe 当模块使用相同版本共享依赖项时,可以使用npm dedupe展平node_modules层次结构

The documentation describes npm dedupe as follows: 该文档描述了npm dedupe ,如下所示:

Searches the local package tree and attempts to simplify the overall structure by moving dependencies further up the tree, where they can be more effectively shared by multiple dependent packages. 搜索本地软件包树,并尝试通过将依赖关系进一步移到树上来简化整体结构,在此树中,多个依赖软件包可以更有效地共享它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM