npm ELIFECYCLE / Exit Status Errors - Diagnose Failing npm Scripts
ELIFECYCLE is npm telling you a script exited non-zero. It is a wrapper - the real failure is in the lines above it.
What this error means
An npm run <script> step fails and npm prints ELIFECYCLE with the script name and an exit status. The actual error (a failed test, a compiler error, a missing file) is printed just before the npm summary.
npm output
> my-app@1.0.0 build
> tsc -p tsconfig.json
src/index.ts:12:7 - error TS2322: Type 'string' is not assignable to type 'number'.
npm error code ELIFECYCLE
npm error errno 2Common causes
The underlying command failed
ELIFECYCLE simply reflects that the command your script ran returned non-zero - a failed build, test, or lint. npm is the messenger, not the cause.
How to fix it
Read above the npm summary
- Scroll up from the
npm error code ELIFECYCLEblock to the real error. - Reproduce the underlying command directly (e.g. run
tsc -p tsconfig.json) to iterate faster. - Fix that error; the ELIFECYCLE disappears with it.
How to prevent it
- Treat ELIFECYCLE as "my script failed", not as an npm bug.
- Surface the real command’s output clearly in CI logs.
Related guides
npm ERESOLVE "unable to resolve dependency tree" - Fix Peer ConflictsFix npm ERESOLVE "unable to resolve dependency tree" peer dependency conflicts in CI - properly, without blin…
Node.js "JavaScript heap out of memory" in CI - Fix FATAL Heap ErrorsFix "FATAL ERROR: Reached heap limit - JavaScript heap out of memory" in CI builds by raising the V8 heap lim…
Exit Codes and Signals in CI/CD: A Practical GuideA practical guide to process exit codes and signals in CI/CD - what 1, 2, 124, 126, 127, 130, 137, and 143 me…