npm node_modules 没有正确嵌套? [英] npm node_modules not being properly nested?

查看:74
本文介绍了npm node_modules 没有正确嵌套?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 npm 时出现意外行为.例如使用以下命令安装 express 时:

I'm getting unexpected behavior when using npm. For example when installing express with the command:

npm install express

我希望在node_modules"目录中创建一个名为express"的文件夹,并且它的依赖项将安装在该文件夹内的node_modules"子目录中.

I would expect that a folder named, "express" would be created in the "node_modules" directory and that it's dependencies would be installed within a "node_modules" sub-directory within this folder.

我看到的是正在创建express"文件夹,但它的所有依赖项都被添加到我的项目文件夹中的根node_modules"目录(与 express 相同级别),而不是嵌套在express"中文件夹.

What I am seeing is that the "express" folder is being created but all of it's dependencies are being added to the root "node_modules" directory (same level as express) in my project folder and not nested within the "express" folder.

为什么会这样?(使用 npm v3.3.5)

Why is this happening? (using npm v3.3.5)

推荐答案

这是 npm@3 的设计更改,默认情况下会进行重复数据删除.见:

It's a design change for npm@3, it deduplicates by default. See:

平,平,平!

您的依赖项现在将安装最平坦.就目前而言可能的,您所有的依赖项,以及它们的依赖项,以及它们的依赖项将安装在您项目的 node_modules 文件夹中,没有嵌套.当两个(或更多) 模块具有相互冲突的依赖关系.

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.

https://github.com/npm/npm/blob/ff47bc7f567f487f567f487f5672110671000/CHANGELOG.md#flat-flat-flat

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

这篇关于npm node_modules 没有正确嵌套?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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