node_modules (Node.js)
node_modules is the folder where npm installs a project's dependencies. Node looks here to resolve package imports, and the folder is generated from package.json rather than committed to source control.
Node.js
When you run npm install, every dependency and sub-dependency is downloaded into node_modules. When your code does require('express') or import 'express', Node searches node_modules folders (starting from the current directory and walking up) until it finds the package.
node_modules is famously large because it contains your dependencies' dependencies, recursively. You should not edit files inside it, and you should add it to .gitignore: it is reproducible from package.json plus package-lock.json, so committing it bloats the repository pointlessly.
To recreate it, you run npm install (or npm ci for an exact, clean install from the lockfile). If installs behave strangely, deleting node_modules and the lockfile and reinstalling is a common reset.
Syntax
node_modules/ (generated; add to .gitignore)Examples
JavaScript
// .gitignore
node_modules/
// recreate from manifest + lockfile
// npm install (or) npm ci