简体   繁体   English

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

[英]Why NPM install Install all node_modules

When I try to install a single module into the project, like gulp, it install all the node_module... 当我尝试将单个模块(例如gulp)安装到项目中时,它将安装所有的node_module ...

I don't know where those module come from, I get like 99 folder into the node_modules foler when I just want to install one. 我不知道这些模块来自哪里,当我只想安装一个模块时,会在node_modules文件中找到99个文件夹。

This is as designed. 这是按设计的。 @ https://docs.npmjs.com/cli/install , it is summarized as: This command installs a package, and any packages that it depends on. @ https://docs.npmjs.com/cli/install ,其摘要为: 此命令将安装软件包以及它所依赖的所有软件包。

Here is the algorithm as defined in the page: 这是页面中定义的算法:

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