npm ELIFECYCLE Error in CI - Diagnose Failing Lifecycle Scripts
ELIFECYCLE is npm reporting that a lifecycle script (preinstall, install, postinstall, or a run script) exited with a non-zero code. The interesting failure is in the lines above it.
What this error means
An install or script step ends with code ELIFECYCLE and a non-zero exit status. The ELIFECYCLE line itself is just the wrapper; the actual error appears just before it in the log.
npm
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@1.0.0 postinstall: `node ./scripts/setup.js`
npm ERR! Exit status 1Common causes
A lifecycle script exited non-zero
A preinstall, postinstall, or prepare script ran a command that failed, and npm surfaces it as ELIFECYCLE.
A missing tool or env var the script relies on
The script calls a binary or reads a variable that is not present in the CI environment, so it errors out.
How to fix it
Read the failing script and reproduce it
- Find the script name and command on the ELIFECYCLE line.
- Run that exact command in the CI shell to see the real error.
- Fix the underlying failure (missing tool, bad path, env var).
Check the full log above the wrapper
- Scroll up from ELIFECYCLE to the first error line.
- Address that error rather than the generic exit status.
How to prevent it
- Keep lifecycle scripts deterministic, declare every tool they need, and guard optional steps so a clean CI environment can run install end to end.
Related guides
npm postinstall Script Failed in CI - Fix Failing postinstall HooksFix npm postinstall script failures in CI by finding what the hook actually runs (native build, download, cod…
npm run build Exited With Code 1 in CI - Diagnose Build FailuresDiagnose "npm run build exited with code 1" in CI by reading the real build error above the npm wrapper inste…
npm ENOENT package.json Not Found in CI - Fix Missing ManifestFix "npm ERR! code ENOENT ... package.json" in CI when npm runs in a directory that has no package.json, usua…