Back to Cheat Sheets
NPM Commands
Basic and advanced commands to manage Node.js packages and projects.
| Action | Command | Details |
|---|---|---|
| Initialize project | npm init |
Create a new package.json interactively. |
| Install package | npm install <package> |
Install a package locally. |
| Install global package | npm install -g <package> |
Install a package globally. |
| Update package | npm update <package> |
Update package to latest version. |
| Uninstall package | npm uninstall <package> |
Remove a package. |
| List installed packages | npm list |
Show installed packages locally. |
| List outdated packages | npm outdated |
Show packages with newer versions. |
| Run script | npm run <script> |
Run a script defined in package.json. |
| Publish package | npm publish |
Publish a package to npm registry. |
| Audit packages | npm audit |
Check for security vulnerabilities. |
| Fix vulnerabilities | npm audit fix |
Automatically fix vulnerabilities. |
| Cache clean | npm cache clean --force |
Clear npm cache. |
| View package info | npm view <package> |
Show package metadata. |