npm Essentials

Version: 10.xPublished: 2026-01-16npm/core

Essential npm commands for Node.js package management.

Project Setup

ExampleDescription
npm init -y
Initialize project
Create package.json with defaults.
npm install
Install dependencies
Install all dependencies from package.json.
npm ci
Clean install
Install exact versions from package-lock.json.

Dependencies

ExampleDescription
npm install lodash
Add package
Install and save as dependency.
npm install -D typescript
Add dev dependency
Install as devDependency.
npm install -g npm-check-updates
Add global
Install package globally.
npm uninstall lodash
Remove package
Remove package and update package.json.
npm ls --depth=0
List installed
Show top-level installed packages.

Scripts

ExampleDescription
npm run build
Run script
Execute a script defined in package.json.
npm test
Run test
Run the test script (shorthand).
npm start
Run start
Run the start script (shorthand).
npm run
List scripts
Show all available scripts.

Updates

ExampleDescription
npm outdated
Check outdated
Show packages with newer versions available.
npm update
Update packages
Update packages within semver range.
npm install -g npm@latest
Update npm
Update npm itself to latest version.

Info & Debug

ExampleDescription
npm info react
View package info
Show registry information for a package.
npm audit
Check for vulnerabilities
Scan dependencies for security issues.
npm audit fix
Fix vulnerabilities
Automatically fix security issues when possible.
npm explain lodash
Why installed
Show why a package is installed.

Publishing

ExampleDescription
npm login
Login
Authenticate with npm registry.
npm publish
Publish
Publish package to registry.
npm version patch
Bump version
Increment version (patch/minor/major).