npm ERR! code ELIFECYCLE in Node.js — What It Means and How to Fix It

What the Node.js/npm error npm ERR! code ELIFECYCLE means and how to resolve it.

Published October 25, 2026

ELIFECYCLE means a script defined in package.json (build, start, test) exited with a non-zero code. The real error is printed above it.

What it means and why it happens

The wrapper message is generic; scroll up to find the first actual error.

Read the full message: it names the file and line where the problem was detected, which is the best place to start.

What you see

run the code
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-app@1.0.0 build: `webpack`

Practical examples

Code that triggers it

"scripts": { "build": "webpack" }   // webpack fails

The fix

npm run build 2>&1 | head -50
# fix the first error reported

Clean reinstall

rm -rf node_modules package-lock.json
npm cache verify
npm install

Common mistakes

  • Reading only the last lines.
  • Mismatched Node versions.
  • Stale node_modules.

Key takeaways

  • npm ERR! code ELIFECYCLE: ELIFECYCLE means a script defined in package.json (build, start, test) exited with a non-zero code.
  • Read the message and the line number first.
  • Fix the cause, don't just silence the error.

FAQ

Where is the real error?

In the lines before ELIFECYCLE.

How do I find which line caused npm ERR! code ELIFECYCLE?

The error message and stack trace show the file and line; start there and work backwards.

More JavaScript articles