NPM Commands Cheatsheet
Quick reference for common NPM commands: installing, uninstalling, scripts, project management, publishing, and package info.
| Command | Description | Example | Category |
|---|---|---|---|
| npm install <package> | Install a package | npm install lodash | Install & Uninstall |
| npm install -g <package> | Install globally | npm install -g typescript | Install & Uninstall |
| npm uninstall <package> | Uninstall a package | npm uninstall lodash | Install & Uninstall |
| npm update <package> | Update a package | npm update react | Install & Uninstall |
| npm init | Create new package.json | npm init | Project & Packages |
| npm init -y | Auto generate package.json | npm init -y | Project & Packages |
| npm list | List installed packages | npm list | Project & Packages |
| npm outdated | Check outdated packages | npm outdated | Project & Packages |
| npm ci | Clean install from package-lock | npm ci | Project & Packages |
| npm run <script> | Run a script from package.json | npm run build | Scripts |
| npm test | Run test script | npm test | Scripts |
| npm start | Run start script | npm start | Scripts |
| npm publish | Publish package to registry | npm publish | Publish & Version |
| npm version <major|minor|patch> | Bump version | npm version patch | Publish & Version |
| npm cache clean --force | Clean npm cache | npm cache clean --force | Others |
| npm config list | List npm config | npm config list | Others |
| npm audit | Check for vulnerabilities | npm audit | Others |