pnpm "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL" in CI
When pnpm -r run <script> executes a script across every workspace package, a non-zero exit in any one package aborts the recursive run and reports it with this code. The real failure is the script output above.
What this error means
A pnpm -r build or pnpm -r test step fails with "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @acme/web@1.0.0 build: Failed" after one package's script exited non-zero.
@acme/web:build: error TS2322: Type 'string' is not assignable to type 'number'.
ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @acme/web@1.0.0 build: FailedCommon causes
A script genuinely failed in one package
The recursive run surfaces the first package whose script exited non-zero; the underlying error (a type error, a failing test) is in the log just above.
Packages built in the wrong order
A package that depends on another was built before its dependency, so it could not find generated output and its script failed.
How to fix it
Fix the failing package's script
- Scroll up to the package name in the error and read its script output.
- Reproduce locally with
pnpm --filter <pkg> run <script>. - Fix the underlying error, then re-run the recursive command.
pnpm --filter @acme/web run buildBuild in topological order
Use pnpm's dependency-aware ordering so each package builds after the packages it depends on.
pnpm -r --workspace-concurrency=1 run buildHow to prevent it
- Reproduce package failures with
--filterbefore running the full recursive command. - Rely on pnpm topological ordering so dependencies build first.
- Keep per-package scripts self-contained so failures are local and clear.