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 packagesCommon 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 buildRelated guides
pnpm "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL" in CIFix pnpm "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL" in CI - a recursive workspace script failed in one package, fail…
pnpm run: Usage, Options & Common Errorspnpm run executes package.json scripts, with --filter and -r to run across workspaces. Usage, arg passing, an…
yarn/pnpm "Couldn't find package on the workspace registry" in CIFix yarn "Couldn't find package X on the \"workspace\" registry" in CI - a workspace dependency whose name or…