npm examples, explained
$ npm install -D typescript
- npmthe Node.js package manager
- installinstall dependencies (or a named package)
- -Dsave to devDependencies
- typescriptan argument passed to the command
$ npm run build
- npmthe Node.js package manager
- runrun a script defined in package.json
- buildan argument passed to the command
$ npm ci --omit=dev
- npmthe Node.js package manager
- ciclean install exactly from the lockfile
- --omit=devexclude a dependency type from install (e.g. dev)
npm subcommands
install — install dependencies (or a named package)i — install dependencies (short for install)run — run a script defined in package.jsontest — run the project's test scriptstart — run the project's start scriptpublish — publish the package to the registryinit — create a package.jsonupdate — update packages to newer allowed versionsuninstall — remove a packageci — clean install exactly from the lockfileexec — run a package's binary
npm flags & options
| -g | operate globally, not on the local project |
| -D | save to devDependencies |
| -S | save to dependencies (default) |
| --save-dev | save to devDependencies |
| --save | save to dependencies |
| --global | operate globally |
| --production | skip devDependencies |
| --omit | exclude a dependency type from install (e.g. dev) |
| --include | force-include a dependency type |
| --force | overwrite conflicts and bypass some checks |
| --legacy-peer-deps | ignore peer-dependency conflicts (npm v7+ behavior) |
| --workspace | run the command for this workspace only |
Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.