繁体   English   中英

为什么要安装NPM安装所有的node_modules

[英]Why NPM install Install all node_modules

当我尝试将单个模块(例如gulp)安装到项目中时,它将安装所有的node_module ...

我不知道这些模块来自哪里,当我只想安装一个模块时,会在node_modules文件中找到99个文件夹。

这是按设计的。 @ https://docs.npmjs.com/cli/install ,其摘要为: 此命令将安装软件包以及它所依赖的所有软件包。

这是页面中定义的算法:

load the existing node_modules tree from disk
clone the tree
fetch the package.json and assorted metadata and add it to the clone
walk the clone and add any missing dependencies
  dependencies will be added as close to the top as is possible
  without breaking any other modules
compare the original tree with the cloned tree and make a list of
actions to take to convert one to the other
execute all of the actions, deepest first
  kinds of actions are install, update, remove and move

暂无
暂无

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

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