Skip to content
Latchkey

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:build

Common 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

  1. Scroll up to the output of the named project:target.
  2. Fix the underlying compiler, test, or lint error.
  3. Re-run just that target to confirm before running the full set.
Terminal
nx run api:build --verbose

Isolate 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=api

How to prevent it

  • Run targets locally before pushing to catch tool failures early.
  • Use --verbose in CI to keep full task output for triage.
  • Keep task dependencies (dependsOn) accurate so failures point to the real project.

Related guides

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