pnpm Cheat Sheet

A fast, disk-efficient package manager with strict dependency resolution and great monorepo support.

Build & Package3 sections · 19 commands
⌘K

Installing

8
pnpm install

Install with a frozen lockfile when present

pnpm add PACKAGE

Add a dependency

pnpm add -D PACKAGE

Dev dependency

pnpm dlx PACKAGE

Run without installing (npx-like)

pnpm list

Installed tree (depth by flag)

pnpm why PACKAGE

Why is a package here

pnpm prune

Remove unused store entries

pnpm store prune

Global store cleanup

Workspaces

6
pnpm -r build

Run a script in all packages

pnpm --filter app build

One workspace only

pnpm --filter app --filter lib test

Multiple filters

pnpm -r --filter './packages/**' test

Filter by glob

pnpm add PACKAGE --filter app

Add into one package

pnpm all

Shorthand for -r

Scripts

5
pnpm run

List scripts

pnpm run build

Run a script

pnpm dev

Shortcut for a dev script

pnpm env use --global 20

Install a Node version

pnpm approve-builds

Accept postinstall scripts