Fix 'npm ERR! code ELIFECYCLE' and 'npm ERR! errno 1' (Script Exited With Status 1)
ELIFECYCLE is a wrapper error: find the real failure above it, then clear caches, reinstall dependencies, or fix the failing script.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-app@1.0.0 build: `next build` npm ERR! Exit status 1
# 1. Capture the full output of the failing script npm run build --verbose 2>&1 | tee build.log # 2. Look for the first real error (TS errors, missing env vars, OOM) grep -n -i -E "error|cannot|not found|heap" build.log | head -20 # 3. Clean reinstall rm -rf node_modules package-lock.json && npm install # 4. Out of memory during build? NODE_OPTIONS="--max-old-space-size=4096" npm run build
Root Cause & Mechanism Analysis
Why does this error occur?
npm only reports that a package.json script (build, start, postinstall) exited with a non-zero code. The real cause — a TypeScript error, missing environment variable, out-of-memory crash, or corrupted node_modules — is printed in the lines above the npm ERR! block.
Frequently Asked Questions
Is ELIFECYCLE an npm bug?
Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?
Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.
Related Developer Error Solutions
Browse All 69 GuidesNode.js: JavaScript heap out of memory
Increase V8 memory allocation using --max-old-space-size and identify memory leaks during builds.
NPM: ERESOLVE unable to resolve dependency tree
Resolve strict peer dependency conflicts in npm 7+ using --legacy-peer-deps or updating outdated packages.
npm ERR! gyp ERR! build error / node-gyp rebuild failed
Install the native build toolchain (Python, make, C++ compiler) or switch to prebuilt / pure-JS alternatives to stop node-gyp failures.