Skip to main content
Ganesh Joshi
Back to Cheatsheets

npm / pnpm / yarn cheat sheet

Updated 2026-02-14

CLI commands for npm, pnpm, and yarn: install, run, add, publish, workspace. Quick reference.

npm

  • npm install

    Install all dependencies.

  • npm install <pkg>

    Add production dependency.

  • npm install -D <pkg>

    Add devDependency.

  • npm ci

    Clean install from lockfile (CI).

  • npm run <script>

    Run script from package.json.

  • npm start / npm test

    Run start or test.

  • npm uninstall <pkg>

    Remove package.

  • npm publish

    Publish to registry.

  • npm init

    Create package.json.

  • npm audit

    Security audit.

pnpm

  • pnpm install

    Install all.

  • pnpm add <pkg>

    Add dependency.

  • pnpm add -D <pkg>

    Add devDependency.

  • pnpm run <script> / pnpm build

    Run script.

  • pnpm remove <pkg>

    Remove package.

  • pnpm -r run build

    Run in all workspaces.

  • pnpm --filter <pkg> run build

    Run in one workspace.

  • pnpm publish

    Publish.

yarn

  • yarn

    Install all.

  • yarn add <pkg>

    Add dependency.

  • yarn add -D <pkg>

    Add devDependency.

  • yarn run <script> / yarn build

    Run script.

  • yarn remove <pkg>

    Remove package.

  • yarn workspaces run build

    Run in all workspaces.

  • yarn workspace <name> run build

    Run in one workspace.

  • yarn publish

    Publish.

npm / pnpm / yarn cheat sheet | Cheatsheet | Ganesh Joshi