ELIFECYCLE 📦 npm

npm ERR! code ELIFECYCLE / Command failed with exit code 1

An npm script (build, start, test, postinstall) exited with an error. ELIFECYCLE is only the wrapper — the real error is printed above it.

Seen on: npm Node.js

Meaning

npm runs the command in package.json scripts and reports ELIFECYCLE / “Lifecycle script failed” when it exits non-zero. Scroll up to the first error from the actual tool (webpack, tsc, jest, node).

Common causes

  • Build/compile error in your code (TypeScript, webpack, Vite)
  • Failing tests
  • Postinstall script of a dependency failing (native modules)
  • Port already in use for npm start
  • Out-of-memory during build (exit code 134/137)

⚡ Quick fix

  1. Scroll up to the first real error above the npm ERR! lines
  2. Run the script command directly to see full output
  3. For memory: NODE_OPTIONS=--max-old-space-size=4096 npm run build
  4. Clean reinstall if a dependency script fails: rm -rf node_modules && npm ci

Detailed fix by platform

npm

  1. Run with verbose logs:
    bash
    npm run build --loglevel verbose
    cat ~/.npm/_logs/*-debug-0.log | tail -50

How to diagnose

  1. First error — What failed before npm ERR!?
  2. Script — Which script and command?
  3. Exit code — 1 = tool error, 134/137 = memory

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.