Nx "Running target failed" nonzero exit in CI
Nx scheduled and ran the target, but the executor (build, test, lint) exited with a nonzero code. Nx surfaces this as a failed target and, with default settings, fails the whole invocation.
What this error means
After running tasks, Nx prints "Running target build for project api failed" with a summary of failed projects. The task output above holds the real error.
Nx
NX Running target build for project api failed
Failed tasks:
- api:buildCommon causes
The wrapped tool failed
The compiler, test runner, or linter behind the target exited nonzero. Nx only reports the failure; the cause is in that tool's output.
A dependent task failed first
A target that this one depends on failed, so Nx reports the downstream target as failed too.
How to fix it
Read the failing task output
- Scroll up to the output of the named
project:target. - Fix the underlying compiler, test, or lint error.
- Re-run just that target to confirm before running the full set.
Terminal
nx run api:build --verboseIsolate one project to debug
Narrow the run to the failing project so its output is not buried among other tasks.
Terminal
nx run-many -t build --projects=apiHow to prevent it
- Run targets locally before pushing to catch tool failures early.
- Use
--verbosein CI to keep full task output for triage. - Keep task dependencies (
dependsOn) accurate so failures point to the real project.
Related guides
Nx target dependsOn references a task not found in CIFix Nx dependsOn referencing a target that does not exist in CI - a task lists a dependency Nx cannot find, s…
Nx "Cannot find configuration for task" in CIFix Nx "Cannot find configuration for task project:target" in CI - the target you asked Nx to run is not decl…
Nx "enforce-module-boundaries" lint violation in CIFix Nx "@nx/enforce-module-boundaries" lint errors in CI - an import crosses a project tag or type boundary t…