npm & Node Quick Reference
npm commands for installing, updating and publishing packages, running scripts, and handy Node.js CLI flags.
4 sections · 22 snippets · updated Oct 14, 2026
Click any snippet to copy it.
Projects & installing
Set up and add dependencies.
TaskCode
- Create package.json
- Install all dependencies
- Add a dependency
- Install a specific version
- Install globally
- Remove a package
Scripts & running
Run tasks and tools.
TaskCode
- Run a script
- Pass arguments to a script
- Run a package without installing
- Run a Node file
- Load a .env file (Node 20.6+)
- Run Node's test runner
Maintenance
Keep dependencies healthy.
TaskCode
- See outdated packages
- Update within ranges
- Check for vulnerabilities
- Why is this installed?
- List installed packages
- Clear the cache
Publishing
Share a package.
TaskCode
- Log in
- Bump the version
- Publish
- Preview what gets published