为什么安装NPM安装所有node_modules

时间:2016-02-26 03:18:37

标签: node.js npm gulp npm-install

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

我不知道这些模块的来源,当我只想安装一个模块时,我将99文件夹放入node_modules文件夹。

1 个答案:

答案 0 :(得分:0)

这是按照设计的。 @ 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
相关问题