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.
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
- Scroll up to the first real error above the npm ERR! lines
- Run the script command directly to see full output
- For memory:
NODE_OPTIONS=--max-old-space-size=4096 npm run build - Clean reinstall if a dependency script fails:
rm -rf node_modules && npm ci
Detailed fix by platform
npm
- Run with verbose logs:bash
npm run build --loglevel verbose cat ~/.npm/_logs/*-debug-0.log | tail -50
How to diagnose
- First error — What failed before npm ERR!?
- Script — Which script and command?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026