Skip to content
Latchkey

pnpm -r (recursive) in Monorepos

pnpm -r applies a command to every package in the workspace.

Recursive commands are the backbone of pnpm monorepo CI: install once, then build and test across packages.

Common usage

  • pnpm -r install
  • pnpm -r run build - topological by default
  • pnpm -r --filter <scope> - subset
  • pnpm -r exec <cmd>

Example in CI

Build all packages in dependency order.

shell
pnpm -r run build

In CI

pnpm orders builds by the dependency graph automatically. For large graphs, faster managed runners shorten the critical path.

Key takeaways

  • pnpm -r runs across all packages.
  • Builds are topological by default.
  • Combine with --filter for subsets.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →