pnpm Cheat Sheet

Comprehensive pnpm CLI reference for installs, dependency management, scripts, filtering, and inspection.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Getting Started

Install pnpm, initialize projects, and get quick help.

Install pnpm with standalone script

Install pnpm via the official standalone script.

bashANYpnpminstallbootstrap
bash
curl -fsSL https://get.pnpm.io/install.sh | sh -
Notes

Install pnpm via the official standalone script.

Set up pnpm on your machine

Creates the pnpm home directory and updates shell configuration as needed.

bashANYpnpmsetupbootstrap
bash
pnpm setup
Notes

Creates the pnpm home directory and updates shell configuration as needed.

Initialize a package

Create a package.json interactively.

bashANYpnpminitpackage.json
bash
pnpm init
Notes

Create a package.json interactively.

Show pnpm help

Display top-level CLI help.

bashANYpnpmhelp
bash
pnpm help
Notes

Display top-level CLI help.

Show help for a command

Display help for a specific subcommand.

bashANYpnpmhelpdocs
bash
pnpm help add
Notes

Display help for a specific subcommand.

Show pnpm version

Print the installed pnpm version.

bashANYpnpmversion
bash
pnpm --version
Notes

Print the installed pnpm version.

Show Node.js version used by pnpm

Check the Node runtime in the current environment.

bashANYpnpmnodeenv
bash
pnpm exec node --version
Notes

Check the Node runtime in the current environment.

Install, Add, Remove, Update

Core package management commands.

Install all dependencies

Install dependencies from package.json and lockfile.

bashANYpnpminstalldeps
bash
pnpm install
Notes

Install dependencies from package.json and lockfile.

Install with frozen lockfile

Fail if the lockfile would need changes; common in CI.

bashANYpnpminstalllockfileci
bash
pnpm install --frozen-lockfile
Notes

Fail if the lockfile would need changes; common in CI.

Install in offline mode

Install using only already-fetched packages from the store.

bashANYpnpminstallofflinestore
bash
pnpm install --offline
Notes

Install using only already-fetched packages from the store.

Add dependency

Add a package to dependencies.

bashANYpnpmadddeps
bash
pnpm add lodash
Notes

Add a package to dependencies.

Add dev dependency

Add a package to devDependencies.

bashANYpnpmadddevDependencies
bash
pnpm add -D typescript
Notes

Add a package to devDependencies.

Add optional dependency

Add a package to optionalDependencies.

bashANYpnpmaddoptionalDependencies
bash
pnpm add -O fsevents
Notes

Add a package to optionalDependencies.

Add exact version

Save an exact version instead of a range.

bashANYpnpmaddversioning
bash
pnpm add react@18.3.1 --save-exact
Notes

Save an exact version instead of a range.

Remove dependency

Remove a package from dependencies.

bashANYpnpmremovedeps
bash
pnpm remove lodash
Notes

Remove a package from dependencies.

Update dependencies

Update dependencies according to the allowed ranges.

bashANYpnpmupdatedeps
bash
pnpm update
Notes

Update dependencies according to the allowed ranges.

Update package to latest

Update a package to the latest available version.

bashANYpnpmupdatelatest
bash
pnpm update react --latest
Notes

Update a package to the latest available version.

Dedupe lockfile

Reduce duplicates in the lockfile when possible.

bashANYpnpmdedupelockfile
bash
pnpm dedupe
Notes

Reduce duplicates in the lockfile when possible.

Import lockfile from npm or Yarn

Generate pnpm-lock.yaml from package-lock.json, npm-shrinkwrap.json, or yarn.lock.

bashANYpnpmimportmigration
bash
pnpm import
Notes

Generate pnpm-lock.yaml from package-lock.json, npm-shrinkwrap.json, or yarn.lock.

Run, Exec, and Inspect

Run scripts, binaries, and inspect dependency state.

Run a package script

Run a script from package.json.

bashANYpnpmrunscripts
bash
pnpm run build
Notes

Run a script from package.json.

Run script via shorthand

Run a script without typing run when there is no command ambiguity.

bashANYpnpmrunscripts
bash
pnpm test
Notes

Run a script without typing run when there is no command ambiguity.

Execute binary in project context

Run a locally installed binary without adding it to PATH manually.

bashANYpnpmexecbinaries
bash
pnpm exec eslint .
Notes

Run a locally installed binary without adding it to PATH manually.

Run one-off package

Download and run a package without permanently installing it.

bashANYpnpmdlxscaffold
bash
pnpm dlx create-vite@latest my-app
Notes

Download and run a package without permanently installing it.

List installed packages

Show installed packages in a tree structure.

bashANYpnpmlistinspect
bash
pnpm list
Notes

Show installed packages in a tree structure.

List top-level packages

Show only top-level dependencies.

bashANYpnpmlistinspect
bash
pnpm list --depth 0
Notes

Show only top-level dependencies.

Explain why a package is present

Show why a package is installed in the dependency graph.

bashANYpnpmwhyinspect
bash
pnpm why react
Notes

Show why a package is installed in the dependency graph.

Show outdated dependencies

List dependencies with newer versions available.

bashANYpnpmoutdatedinspect
bash
pnpm outdated
Notes

List dependencies with newer versions available.

Audit dependencies

Scan dependencies for known vulnerabilities.

bashANYpnpmauditsecurity
bash
pnpm audit
Notes

Scan dependencies for known vulnerabilities.

Attempt audit fixes

Try to apply non-breaking security updates automatically.

bashANYpnpmauditsecurityfix
bash
pnpm audit --fix
Notes

Try to apply non-breaking security updates automatically.

Print store path

Show the location of the content-addressable store.

bashANYpnpmstoreinspect
bash
pnpm store path
Notes

Show the location of the content-addressable store.

Filtering and Recursive Execution

Target specific workspace packages and run recursively.

Install across workspace

Run install recursively across workspace packages.

bashANYpnpmworkspacerecursive
bash
pnpm -r install
Notes

Run install recursively across workspace packages.

Run build in all workspace packages

Run a script recursively in all packages.

bashANYpnpmworkspacerecursivescripts
bash
pnpm -r run build
Notes

Run a script recursively in all packages.

Operate on one workspace package

Limit a command to a selected workspace package.

bashANYpnpmworkspacefilter
bash
pnpm --filter @acme/web test
Notes

Limit a command to a selected workspace package.

Filter package and dependents

Target a package and packages that depend on it.

bashANYpnpmworkspacefilterdependents
bash
pnpm --filter @acme/ui... build
Notes

Target a package and packages that depend on it.

Filter package and its deps

Target a package and its dependency chain.

bashANYpnpmworkspacefilterdependencies
bash
pnpm --filter ...@acme/api test
Notes

Target a package and its dependency chain.

Filter by directory

Target packages by path selector.

bashANYpnpmworkspacefilterpath
bash
pnpm --filter ./packages/web... lint
Notes

Target packages by path selector.

Run in parallel

Run a script in parallel across packages.

bashANYpnpmworkspaceparallel
bash
pnpm -r --parallel run dev
Notes

Run a script in parallel across packages.

Stream prefixed output

Stream real-time output from recursive runs.

bashANYpnpmworkspaceoutput
bash
pnpm -r --stream test
Notes

Stream real-time output from recursive runs.

Recommended next

No recommendations yet.