npm Cheatsheet - Node.js Package Manager Reference
A Node project is only as reproducible as your dependency commands. This reference runs the whole lifecycle: init/scaffold, install/update/remove, version ranges and package-lock, npm scripts and npx, npm ls/audit/outdated for health, publishing, and config/cache handles. Compare to a bare command list, it also flags lockfile and audit subtleties that bite teams. Use it when CI fails on dependency resolution or a package won't install at the expected version. After reading you operate dependencies and debug install issues with intent.
Project Init 4
npm init -ynpm initnpm init <initializer> [args]npm create <initializer>@latestInstall & Uninstall 7
npm installnpm install <pkg>npm install -D <pkg>npm install -g <pkg>npm install <pkg> --save-exactnpm uninstall <pkg>npm uninstall -g <pkg>Version Management 6
npm install <pkg>@1.2.3npm install <pkg>@latestnpm install <pkg>@^1.0.0npm update [pkg]npm outdatednpm dedupeScripts & Run 6
npm run <script>npm startnpm testnpm runnpx <command> [args]npm run <script> -- --port 8080Dependency Inspection 6
npm lsnpm ls --depth=0npm ls <pkg>npm why <pkg>npm auditnpm audit fixPublish & Release 5
npm version <patch|minor|major>npm publishnpm publish --tag betanpm deprecate <pkg>@<ver> "reason"npm owner add <user> [<pkg>]Config & Cache 7
npm config get registrynpm config set registry https://registry.npmmirror.comnpm config set <key> <value>npm config listnpm cache clean --forcenpm cache verifynpm ciTips
- npm install with no args installs all deps from package.json.
- Commit package-lock.json to lock dependency versions.
- npx runs a package without a global install, e.g. npx create-react-app my-app.
- npm ci is faster and more reliable than npm install; needs a lockfile.
- Set registry.npmmirror.com for a faster mirror in China.
- audit fix --force may introduce breaking changes; be careful in production.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us