Skip to main content

What does node_modules store?

node_modules is the folder where npm (or yarn/pnpm) stores all of a project's installed dependencies, along with their nested dependencies.


What exactly is in there

  1. Core dependencies from package.json (dependencies and devDependencies) Every installed package ends up in node_modules.
  2. Nested dependencies If your library depends on another library, that one gets installed inside node_modules too, even if you never listed it directly.
  3. Compiled artifacts Some packages contain compiled binary files (for example, for Node modules written in C/C++).
  4. npm ecosystem service files For example, .bin, a folder with executable files for CLI packages.

Notable traits

  • A large structure node_modules can take up hundreds of megabytes or even gigabytes because of nested dependencies.

  • Not stored in the repository This folder is usually added to .gitignore, because it is easily restored with the command:

    bash
    npm install
  • Readability is secondary The folder is not meant for manual editing, it is npm's internal structure.


Summary

node_modules stores the full set of libraries a project needs to run, including their nested dependencies and service files. It is effectively an "installed version of the ecosystem", built from the data in package.json and package-lock.json.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.