npm node_modules是否没有正确嵌套?

标签 npm

使用npm时出现意外行为。例如,使用命令安装express时:

npm install express

我希望将在“node_modules”目录中创建一个名为“express”的文件夹,并且其依赖项将安装在此文件夹的“node_modules”子目录中。

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

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

最佳答案

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

Flat, flat, flat!

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/ff47bc138e877835f1c0f419fea5f5672110678a/CHANGELOG.md#flat-flat-flat

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

关于npm node_modules是否没有正确嵌套?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32926251/

相关文章:

json - Typescript 提示导入的 json 模块缺少分号

mysql - 为什么选择二进制 (16) PK 而不是复合 key ?

javascript - Webpack 将代码拆分为通过 npm 包含的单独模块,如何编译 es6?

javascript - 为什么要全局安装 npm 包?

windows - npm cordova 警告引擎窗口

NPM 报告的 Github 引用已过时

node.js - 为什么无法列出全局安装的 npm 模块?

android - react native "Execution failed for task: ' :app:processDebugManifest' after adding Admob module

npm - 如何将 npm-shrinkwrap.json 转换为 package-lock.json 文件?

node.js - 使用phonegap/cordova时,“node”不被识别为内部或外部命令、可操作程序或批处理文件