简体   繁体   English

node_modules文件夹中的许多未知模块

[英]Many unknown modules in node_modules folder

I am new to nodejs. 我是nodejs的新手。 And I found that there are many unknown modules in node_modules folder after I installed three modules (express, jade, gulp) in my local project. 当我在本地项目中安装了三个模块(express,jade,gulp)后,我发现在node_modules文件夹中有许多未知模块。

Unknown module examples in the node_modules: node_modules中的未知模块示例:

  • vary 变化
  • statuses 状态
  • send 发送
  • promise 诺言

From the tutorials I see from others, after they installed gulp, there will be only one "gulp" folder in their node_modules folder, but this is not my case. 从我从其他人那里看到的教程中,他们安装了gulp之后,他们的node_modules文件夹中将只有一个“ gulp”文件夹,但这不是我的情况。 Why? 为什么? Thank you. 谢谢。

The node package manager ( npm ) updated recently, as part of that update, all modules are installed in the top level node_modules folder. 节点软件包管理器( npm )最近更新了,作为该更新的一部分,所有模块都安装在顶级node_modules文件夹中。 This includes modules that your dependencies need to install. 这包括依赖项需要安装的模块。 In the past these modules would be nested inside another node_modules folder in express (for example). 过去,这些模块将嵌套在express另一个node_modules文件夹中(例如)。

This is why the tutorials you read say different, likely they were written before this update. 这就是为什么您阅读的教程说的不同,可能是在此更新之前编写的。

It is mentioned in the npm changelog here 它在npm changelog中提到

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. 在可能的情况下,所有依赖项及其依赖项和THEIR依赖项都将安装在项目的node_modules文件夹中,而不会嵌套。 You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies. 当两个(或更多)模块具有相互依赖的依赖关系时,您只会看到模块彼此嵌套。

#3697 This will hopefully eliminate most cases where windows users ended up with paths that were too long for Explorer and other standard tools to deal with. #3697这有望消除大多数Windows用户最终使用路径而导致Explorer和其他标准工具无法处理的情况。

#6912 (#4761 #4037) This also means that your installs will be deduped from the start. #6912(#4761#4037)这也意味着您的安装将从一开始就被删除。

#5827 This deduping even extends to git deps. #5827此重复数据删除甚至扩展到git deps。

#6936 (#5698) Various commands are dedupe aware now. #6936(#5698)现在可以识别各种重复数据删除命令。 This has some implications for the behavior of other commands: 这对其他命令的行为有一些影响:

npm uninstall removes any dependencies of the module that you specified that aren't required by any other module. npm uninstall会删除您指定的模块的任何其他模块不需要的依赖项。 Previously, it would only remove those that happened to be installed under it, resulting in left over cruft if you'd ever deduped. 以前,它只会删除恰好安装在其下的那些文件,如果您进行了重复数据删除,则会导致剩余的文件残骸。 npm ls now shows you your dependency tree organized around what requires what, rather than where those modules are on disk. 现在,npm ls会向您显示依赖项树,它围绕什么需要什么而组织,而不是那些模块在磁盘上的位置。

#6937 npm dedupe now flattens the tree in addition to deduping. #6937 npm重复数据删除现在除了对重复数据删除之外还使树变平。 And bundling of dependencies when packing or publishing changes too: 在打包或发布更改时也捆绑依赖项:

#2442 bundledDependencies no longer requires that you specify deduped sub deps. #2442 bundledDependencies不再要求您指定重复数据删除子dep。 npm can now see that a dependency is required by something bundled and automatically include it. 现在,npm可以看到捆绑的东西需要依赖,并自动包含它。 To put that another way, bundledDependencies should ONLY include things that you included in dependencies, optionalDependencies or devDependencies. 换句话说,bundleDependencies仅应包括您包含在依赖项,optionalDependencies或devDependencies中的内容。

#5437 When bundling a dependency that's both a devDependency and the child of a regular dependency, npm bundles the child dependency. #5437捆绑既是devDependency又是常规依赖项的子项的依赖项时,npm会捆绑子项依赖项。 As a demonstration of our confidence in our own work, npm's own dependencies are now flattened, deduped, and bundled in the npm@3 style. 为了证明我们对自己的工作充满信心,现在以npm @ 3样式对npm自己的依赖项进行了展平,重复数据删除和捆绑。 This means that npm@3 can't be packed or published by npm@2, which is something to be aware of if you're hacking on npm. 这意味着npm @ 2不能打包或发布npm @ 3,如果您在npm上进行黑客攻击,则需要注意这一点。

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

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