简体   繁体   中英

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...

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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