gpt4 book ai didi

node.js - node_modules 文件夹中有许多未知模块

转载 作者:太空宇宙 更新时间:2023-11-04 00:47:18 24 4
gpt4 key购买 nike

我是nodejs新手。我在本地项目中安装了三个模块(express、jade、gulp)后发现node_modules文件夹中有很多未知模块。

node_modules 中的未知模块示例:

  • 因人而异
  • 状态
  • 发送
  • promise

从我从其他人那里看到的教程来看,他们安装gulp后,他们的node_modules文件夹中只会有一个“gulp”文件夹,但我的情况不是这样。为什么?谢谢。

最佳答案

Node 包管理器 (npm) 最近更新,作为该更新的一部分,所有模块都安装在顶级 node_modules 文件夹中。这包括您的依赖项需要安装的模块。过去,这些模块会嵌套在 express 中的另一个 node_modules 文件夹中(例如)。

这就是为什么您阅读的教程有所不同,很可能它们是在此更新之前编写的。

npm 变更日志中提到了 here

Your dependencies will now be installed maximally flat. Insofar as ispossible, all of your dependencies, and their dependencies, and THEIRdependencies will be installed in your project's node_modules folderwith no nesting. You'll only see modules nested underneath one anotherwhen 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 standardtools to deal with.

#6912 (#4761 #4037) This also means that your installs will be deduped from the start.

#5827 This deduping even extends to git deps.

#6936 (#5698) Various commands are dedupe aware now. This has some implications for the behavior of other commands:

npm uninstall removes any dependencies of the module that youspecified that aren't required by any other module. Previously, itwould only remove those that happened to be installed under it,resulting in left over cruft if you'd ever deduped. npm ls now showsyou your dependency tree organized around what requires what, ratherthan where those modules are on disk.

#6937 npm dedupe now flattens the tree in addition to deduping. And bundling of dependencies when packing or publishing changes too:

#2442 bundledDependencies no longer requires that you specify deduped sub deps. npm can now see that a dependency is required by somethingbundled and automatically include it. To put that another way,bundledDependencies should ONLY include things that you included independencies, optionalDependencies or devDependencies.

#5437 When bundling a dependency that's both a devDependency and the child of a regular dependency, npm bundles the child dependency. As ademonstration of our confidence in our own work, npm's owndependencies are now flattened, deduped, and bundled in the npm@3style. 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.

关于node.js - node_modules 文件夹中有许多未知模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34159318/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com