Skip to content
Latchkey

pnpm recursive (-r): Usage & Common Errors

Run a command across every workspace package.

pnpm -r (--recursive) applies a command to all packages in a workspace, in dependency (topological) order - the backbone of pnpm monorepo builds.

What it does

Executes the command (run, exec, install, update, publish, etc.) in each workspace package, ordering by the dependency graph so dependencies build before dependents. --filter narrows the set; --no-bail collects all failures instead of stopping at the first.

Common usage

Terminal
pnpm -r run build           # build every package, topo order
pnpm -r --filter ./apps/* run test
pnpm -r exec rm -rf dist    # run a command in each package
pnpm -r publish             # publish all publishable packages

Common CI error: recursive build halts on first failure

pnpm -r run build stops as soon as one package fails, hiding other breakages. Add --no-bail so the recursive run continues and CI reports every failing package at once, and use --filter to re-run just the broken one.

.github/workflows/ci.yml
pnpm -r --no-bail run build

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →