Errornpm

npm ERR! code ELIFECYCLE

What npm ERR! code ELIFECYCLE actually reports, why the real cause is always logged above it, and how to find and fix the script that failed.

Last updated

Errornpm
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@1.0.0 build: `next build`
npm ERR! Exit status 1

What it means: npm is reporting that a script it ran (build, test, start, or any other package.json script) exited with a non-zero status — ELIFECYCLE is just npm's label for 'the script failed', not a diagnosis of why.

Likely causes

Most probable first — with how to confirm.

  • 1.The underlying command itself failed — a compile error, a failing test, or a thrown exception — scroll up in the log above the ELIFECYCLE lines to find the actual error; that's the real cause.
  • 2.A missing or mismatched dependency makes the script crash before it can even finish — check `node -v` against the `engines` field in package.json if the failure looks environment-related.
  • 3.The script references a binary or file that doesn't exist, often a typo in package.json's `scripts` block or a build step that got skipped — run the underlying command directly to see the raw error without npm's wrapper.
  • 4.The script ran out of memory partway through (common on `build` scripts over large codebases) — check for a heap-related error above ELIFECYCLE rather than assuming it's a code bug.

Fixes

Safest first; destructive ones are called out.

  • Scroll up to the actual error printed above 'npm ERR! code ELIFECYCLE' and fix that — the ELIFECYCLE line itself never states the cause.
  • Re-run the failing command directly (e.g. `next build`, `tsc`, `jest`) without npm's wrapper for cleaner, unfiltered output.
  • If the failure looks dependency-related, delete `node_modules` and reinstall from the lockfile (`rm -rf node_modules && npm install`) — safe, though slower since everything re-downloads.
  • Confirm your local Node version matches what the project expects; a mismatch can make an otherwise-correct script crash.

Related in Errors