NPM Cheat Sheet
Complete NPM command reference. Install, update, remove packages. Run scripts, publish packages, manage cache. Essential for Node.js development workflows.
NPM Commands (35)
Install
npm install
Install all dependencies
Install
npm install <package>
Install package
Install
npm install <package>@version
Install specific version
Install
npm install -g <package>
Install globally
Install
npm install --save-dev <pkg>
Install as dev dependency
Install
npm ci
Clean install from lock file
Update
npm update
Update all packages
Update
npm update <package>
Update specific package
Update
npm outdated
Check outdated packages
Remove
npm uninstall <package>
Remove package
Remove
npm uninstall -g <package>
Remove global package
Remove
npm prune
Remove extraneous packages
Run
npm run <script>
Run package.json script
Run
npm test
Run test script
Run
npm start
Run start script
Run
npm build
Run build script
Info
npm list
List installed packages
Info
npm list --depth=0
List top-level packages
Info
npm list -g
List global packages
Info
npm view <package>
View package info
Info
npm view <package> versions
View all versions
Cache
npm cache clean
Clear npm cache
Cache
npm cache verify
Verify cache integrity
Publish
npm publish
Publish package
Publish
npm version <type>
Bump version (major/minor/patch)
Publish
npm deprecate <pkg> "msg"
Deprecate package
Init
npm init
Create package.json
Init
npm init -y
Create package.json with defaults
Config
npm config list
Show npm config
Config
npm config set <key> <value>
Set config value
Config
npm config get <key>
Get config value
Other
npm audit
Check for vulnerabilities
Other
npm audit fix
Fix vulnerabilities
Other
npm doctor
Check npm environment
Other
npx <package>
Run package without install
Common package.json Scripts
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js",
"test": "jest",
"build": "webpack --mode production"
}
"start": "node index.js",
"dev": "nodemon index.js",
"test": "jest",
"build": "webpack --mode production"
}
NPM vs Yarn vs PNPM
NPM
npm install
npm run test
npm publish
npm run test
npm publish
Yarn
yarn install
yarn test
yarn publish
yarn test
yarn publish
PNPM
pnpm install
pnpm test
pnpm publish
pnpm test
pnpm publish