Skip to content
Latchkey

pnpm run and pnpm -r run

pnpm run executes a package script; add -r to run it everywhere.

In a pnpm monorepo, pnpm -r run build builds every package, optionally in topological order.

Common usage

  • pnpm run <script>
  • pnpm -r run <script> - all workspaces
  • pnpm --filter <pkg> run <script>
  • --workspace-concurrency - limit parallelism

Example in CI

Test only changed packages and their dependents.

shell
pnpm --filter "...[origin/main]" run test

In CI

The ...[ref] filter needs full git history (fetch-depth: 0). A non-zero script exit fails the job.

Key takeaways

  • pnpm -r run runs across workspaces.
  • --filter "...[ref]" needs fetch-depth: 0.
  • Non-zero exit fails CI.

Related guides

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