NPM Commands Cheatsheet — Essential Reference

npm (Node Package Manager) is the default package manager for the JavaScript runtime environment Node.js. It's used for installing, sharing, and managing code packages (modules) for your projects.

Last updated: 2026-06-11

RECOMMENDED

Master NPM with Top Reference Books

Level up your DevOps skills. Find the best guide books and cheatsheet references for your engineering stack.

Search on Amazon →

Commands

Command Description Example
npm init Initializes a new Node.js project, creating a package.json file. npm init -y
npm install Installs all dependencies listed in package.json. Can also install specific packages. npm install express
npm install --save-dev Installs a package as a development dependency (only needed during development). npm install --save-dev jest
npm uninstall Uninstalls a package from your project. npm uninstall lodash
npm update Updates packages to their latest compatible versions. npm update
npm run <script-name> Executes a custom script defined in the 'scripts' section of package.json. npm run start
npm outdated Checks for outdated packages in your project. npm outdated
npm publish Publishes a package to the npm registry (requires login). npm publish

Pro Tips

  • Use `npx` to run executables from npm packages without installing them globally.
  • Understand `package-lock.json` for consistent installations across environments.
  • Leverage `npm audit` to identify and fix security vulnerabilities in your dependencies.

Frequently Asked Questions

What is npm used for?

npm is primarily used for managing project dependencies, sharing reusable code, and automating development tasks through scripts.

How do I install npm?

npm is bundled with Node.js. To install npm, you need to install Node.js from its official website (nodejs.org). Once Node.js is installed, npm will be available in your terminal.