[Solved] Node.js node_modules?


Node.js node_module` is heaviest object

Because of the dependency of EVERY single npm module you have install, it will be download all dependency and store into your node_modules folder.

Let have a simple example here.

You have a npm module module A which dependent on module B. Therefore the structure of your node_modules folder will be

node_modules
↳ moduleA
  ↳ node_modules
    ↳ moduleB

Now, you install another npm module module C which dependent on module A, and here comes the problem of the folder structure.

node_modules
↳ moduleA (duplicated)
  ↳ node_modules
    ↳ moduleB
↳ moduleC
  ↳ node_modules
    ↳ moduleA (duplicated)
      ↳ node_modules
        ↳ moduleB

As you can see the folder structure of your npm module dependency, it build up the folder size bigger and bigger. The more dependency you require the heavier the node_module you get.

Hope it help you to understand why it explain as the heaviest object

solved Node.js node_modules?