$ command-helper

npm, pnpm, yarn

Installing dependencies, scripts, outdated and vulnerable packages, publishing, nvm.

Requires Google sign-in

Dependencies

Install from lockfile (CI)
npm ci

pnpm 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 install

Updates and security

Outdated packages
npm outdated
Update within semver ranges
npm update
Upgrade a package to the latest major
npm install <package>@latest
Known vulnerabilities
npm audit
Interactively upgrade everythingadvanced
npx npm-check-updates -i

Scripts 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=0
Bump the version and create a git tagadvanced
npm version patch
Preview what will be publishedadvanced
npm pack --dry-run
Publish a packageadvanced
npm publish --access public

Node versions

Install and use the LTS version (nvm)
nvm install --lts && nvm use --lts
Use the version from .nvmrc
nvm use
Enable pnpm and yarn via corepack
corepack enable