Skip to content
Latchkey

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 1

Common 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

  1. Find the script name and command on the ELIFECYCLE line.
  2. Run that exact command in the CI shell to see the real error.
  3. Fix the underlying failure (missing tool, bad path, env var).

Check the full log above the wrapper

  1. Scroll up from ELIFECYCLE to the first error line.
  2. 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

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