Skip to content
Latchkey

npm run build Exited With Code 1 in CI - Diagnose Build Failures

Exit code 1 from npm run build just means the underlying build tool failed. The actionable error is in the tool output above the npm wrapper lines.

What this error means

The build step ends with Process completed with exit code 1 and an npm ELIFECYCLE wrapper. The real failure (a type error, a missing import, a failed bundle) is printed just before it.

npm
> my-app@1.0.0 build
> tsc && vite build

src/index.ts:12:7 - error TS2322: Type 'string' is not assignable
to type 'number'.
npm ERR! code 1

Common causes

The build tool reported an error

tsc, vite, webpack, or another tool failed (type error, lint error, broken import) and exited non-zero.

A CI-only difference

Stricter type checking, missing env vars, or case-sensitive filesystems surface a failure that does not appear locally.

How to fix it

Read the error above the wrapper

  1. Scroll up from the exit-code line to the first tool error.
  2. Fix that specific error rather than the generic exit code.

Reproduce the CI build locally

  1. Run the same build command with the same Node version.
  2. Account for case-sensitive imports and required env vars.
Terminal
npm run build

How to prevent it

  • Run the exact CI build locally before pushing, pin the Node version, and fix type, lint, and import errors at their source so the build exits clean.

Related guides

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