Node_modules
node_modules is the conventional directory in a Node.js project where installed packages and their dependencies are stored.
Secrets of the JavaScript Ninja, Third Edition
The conventional directory in a Node.js project that contains installed JavaScript packages.
- How it is used
- Holds installed dependency trees and supports package-name imports in Node.js projects.
- How deep it goes
- Explains directory search, nested package versions, and entry-point precedence, while deferring the details of exports mappings.
- Examples
- Uses an Express install and import, plus a nested directory tree containing two lodash versions.
- What you can do after
- Diagnose/debug with it by tracing where a package-name import resolves and why different dependencies may load different versions.
Read how Secrets of the JavaScript Ninja, Third Edition explains node_modules →
Fast by Default
The node_modules directory is the filesystem directory containing installed Node.js packages and their transitive dependencies.
- How it is used
- Controls Node.js deployment size by exposing package duplication, oversized dependencies, and development-only contents.
- How deep it goes
- Explains directory measurement, dependency-tree inspection, deduplication, package-size auditing, and production exclusion, but not package internals.
- Examples
- Uses npm ls --all, disk-usage ranking, npm-size, and cost-of-modules to inspect dependency structure and installed size.
- What you can do after
- Diagnose with npm inspection tools, remove unnecessary dependencies, deduplicate versions, and produce leaner production installations.
Road to Kubernetes
The node_modules directory is the local filesystem directory containing installed Node.js packages and their dependencies.
- How it is used
- Uses node_modules for local Node.js dependencies, excludes it from Git, and recreates it during container builds.
- How deep it goes
- Explains contents, deletion, recovery, tracking files, and container placement, but does not examine package internals.
- Examples
- Uses npm install, a Node.js .gitignore entry, and a Dockerfile that installs dependencies under /app.
- What you can do after
- Operate/configure Node.js dependencies by ignoring, deleting, restoring, and containerizing node_modules with npm.
Also covered in
- Essential TypeScript 5, Third Edition
- Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform
What to know first
- JavaScriptJavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
- dependencyA dependency is a component, resource, or prerequisite that another software component or activity relies on to function, build, or proceed.
Related concepts
- npm installproduced by · npm install is an npm command that resolves and installs the dependencies declared by a JavaScript or Node.js package.
- packagehas part · A software package is a named unit that groups related software components, either for organization and compilation or for distribution and reuse.
- bare specifierused by · A bare specifier is a module specifier that identifies a package or module without a relative or absolute path prefix.
- dockerignoreconfigured by · A .dockerignore file specifies patterns for files and directories that Docker excludes from a build context.
- npmproduced by · npm is a package-management system for JavaScript that includes a command-line client and an online registry for discovering, installing, and publishing packages.
Questions about node_modules
What is node_modules?
node_modules is the conventional directory in a Node.js project where installed packages and their dependencies are stored.
Which Manning books explain node_modules?
Secrets of the JavaScript Ninja, Third Edition, Fast by Default and Road to Kubernetes.
What should I know before learning node_modules?
Manning books that teach node_modules usually introduce JavaScript and dependency first.
What are the parts of node_modules?
Node_modules includes package.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


