pnpm Most Important Commands
A quick reference of the pnpm commands you reach for every day.
Install everything
pnpm install
Equivalent:
pnpm i
In CI:
pnpm install --frozen-lockfile
This fails if pnpm-lock.yaml is out of sync.
Add dependency
pnpm add react
Dev dependency:
pnpm add -D typescript
Global package:
pnpm add -g vercel
Add to workspace root:
pnpm add -w -D typescript
Remove dependency
pnpm remove lodash
Alias:
pnpm rm lodash
Run scripts
pnpm dev
pnpm build
pnpm test
Or explicitly:
pnpm run dev
pnpm run executes scripts from package.json. (pnpm)
Execute local binaries
pnpm exec vite
pnpm exec eslint .
pnpm exec runs commands in the project context and adds node_modules/.bin to PATH. (pnpm)
Run a package without installing it permanently
pnpm dlx create-vite
pnpm dlx shadcn@latest init
pnpm dlx fetches a package temporarily and runs its exposed binary. (pnpm)
Update dependencies
pnpm update
Interactive upgrade:
pnpm update --interactive
Latest versions:
pnpm update --latest
List dependencies
pnpm list
Why is this package installed?
pnpm why react
Clean/store commands
Show store path:
pnpm store path
Prune unused packages from store:
pnpm store prune
Workspace filtering
Run command only for one package:
pnpm --filter @acme/web build
Run tests for package and dependencies:
pnpm --filter @acme/web... test
Run for packages changed since branch:
pnpm --filter "...[origin/main]" test
This is extremely useful in monorepos.