npm Cheatsheet

A practical quick reference for everyday npm commands.


Installation & Setup

Check npm Version

npm --version

Initialize a Project

npm init -y

Set npm Config

npm config set init-author-name "Your Name"

Dependency Management

Install Dependency

npm install package-name

Install Dev Dependency

npm install --save-dev package-name

Install Global Package

npm install -g package-name

Remove Dependency

npm uninstall package-name

Update Dependency

npm update package-name

Scripts

Run Script

npm run script-name

Start / Build / Test

npm run start
npm run build
npm test

Package Info

List Installed Packages

npm list --depth=0

View Package Info

npm view package-name

Check Outdated Packages

npm outdated

Cache & Cleanup

Verify npm Cache

npm cache verify

Clean npm Cache

npm cache clean --force

Reinstall All Dependencies

rm -rf node_modules package-lock.json
npm install