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 1Common 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
- Scroll up from the exit-code line to the first tool error.
- Fix that specific error rather than the generic exit code.
Reproduce the CI build locally
- Run the same build command with the same Node version.
- Account for case-sensitive imports and required env vars.
Terminal
npm run buildHow 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
npm ELIFECYCLE Error in CI - Diagnose Failing Lifecycle ScriptsFix "npm ERR! code ELIFECYCLE" during install in CI by finding the lifecycle script that exited non-zero and…
JavaScript Heap Out of Memory in npm Build (CI) - Fix Fatal Heap ErrorsFix "FATAL ERROR: ... JavaScript heap out of memory" during an npm build in CI by raising the V8 heap limit a…