npm / yarn / pnpm Cheatsheet
Same operations, three package managers. Pick one per project and stick with it.
1 credit
Install
6 itemsAll deps
npm install / yarn / pnpm installSingle dep
npm i react / yarn add react / pnpm add reactDev dep
npm i -D eslint / yarn add -D / pnpm add -DGlobal
npm i -g pm2 / yarn global add / pnpm add -gExact version
npm i react@18.2.0 --save-exactClean reinstall
rm -rf node_modules lockfile && installCI-safe install
2 itemsFast, uses lock exactly
npm ci / yarn install --frozen-lockfile / pnpm install --frozen-lockfileSkip optional / dev
npm ci --omit=dev --omit=optionalScripts & running
3 itemsRun script
npm run dev / yarn dev / pnpm devArgs to script
npm run test -- --watch (yarn/pnpm drop the --)Run a binary w/o install
npx cowsay hi / pnpm dlx cowsay hiInspect & update
4 itemsOutdated deps
npm outdated / yarn outdated / pnpm outdatedAudit vulnerabilities
npm audit / yarn npm audit / pnpm auditWhy is pkg installed
npm ls <pkg> / yarn why <pkg> / pnpm why <pkg>Upgrade interactively
npx npm-check-updates -i