coderef

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.

  • Create package.json
  • Install all dependencies
  • Add a dependency
  • Install a specific version
  • Install globally
  • Remove a package

Scripts & running

Run tasks and tools.

  • 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.

  • See outdated packages
  • Update within ranges
  • Check for vulnerabilities
  • Why is this installed?
  • List installed packages
  • Clear the cache

Publishing

Share a package.

  • Log in
  • Bump the version
  • Publish
  • Preview what gets published

← All quick references