npm prune: Usage, Options & Common Errors
Remove extraneous packages from node_modules.
npm prune deletes installed packages that are not declared in package.json - useful for trimming production images after a full install.
What it does
Removes node_modules entries that are not listed as dependencies. With --omit=dev it also removes devDependencies, leaving only what production needs. With --dry-run it reports what it would remove.
Common usage
Terminal
npm prune # remove extraneous packages
npm prune --omit=dev # strip devDependencies for prod
npm prune --dry-run # preview removalsCommon CI pattern: slim the production image
A Docker image ships dev tooling because the build did a full install. After building, prune dev dependencies so the runtime layer carries only production deps - or use npm ci --omit=dev directly when no build-time dev deps are needed.
Dockerfile
RUN npm ci && npm run build && npm prune --omit=devRelated guides
npm dedupe: Usage & Common Errorsnpm dedupe flattens duplicate dependencies in node_modules to reduce install size and conflicts. Usage, what…
npm ci: Usage, Options & Common CI Errorsnpm ci does a clean, reproducible install from package-lock.json - the right command for CI. Usage, flags, an…
npm install: Usage, Options & Common CI ErrorsWhat npm install does, the flags you actually use, and the install failures that break CI builds - ERESOLVE,…