npm, pnpm, yarn
Installing dependencies, scripts, outdated and vulnerable packages, publishing, nvm.
Dependencies
Install from lockfile (CI)
npm cipnpm install --frozen-lockfile · yarn install --immutable
Add a dependency
npm install <package>
pnpm add <pkg> · yarn add <pkg>
Add a dev dependency
npm install -D <package>
Remove a dependency
npm uninstall <package>
Why is a package installed
npm explain <package>
pnpm why <pkg> · yarn why <pkg>
Clean reinstall
rm -rf node_modules package-lock.json && npm installUpdates and security
Outdated packages
npm outdatedUpdate within semver ranges
npm updateUpgrade a package to the latest major
npm install <package>@latest
Known vulnerabilities
npm auditInteractively upgrade everythingadvanced
npx npm-check-updates -iScripts and running
Run a package.json script
npm run <script>
Pass arguments to a script
npm run <script> -- --watch
Run a CLI without installing
npx <package>
Run a script in one workspaceadvanced
npm run <script> -w <workspace>
pnpm --filter <workspace> <script>
Info and publishing
Available versions of a package
npm view <package> versions --json
Top-level installed packages
npm ls --depth=0Bump the version and create a git tagadvanced
npm version patchPreview what will be publishedadvanced
npm pack --dry-runPublish a packageadvanced
npm publish --access publicNode versions
Install and use the LTS version (nvm)
nvm install --lts && nvm use --ltsUse the version from .nvmrc
nvm useEnable pnpm and yarn via corepack
corepack enable