NPM将依赖项安装在错误的位置

问题描述:

我只是在一个文件夹中运行一个简单的npm install morgan,由于某种原因,它会将所有子依赖项添加到父文件夹中.查看所附图片

I just run a simple npm install morgan in a folder and for some reason it adds all the sub dependencies to the parent folder. See image attached

是的,这是npm 3.x中的一项新功能,您可以在此处阅读:

Yes, this is a new feature in npm 3.x, you can read about it here:

https://github.com/npm/npm/releases/tag/v3.0.0

您的依赖项现在将安装为最大程度.在可能的情况下,所有依赖关系及其依赖关系和THEIR依赖关系都将安装在项目的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.

基本上,它现在使用尽可能少的嵌套来处理依赖项.

Basically, it now handles dependencies with as little nesting as possible.