What This Error Means
An npm script failed (a lifecycle script exited with a non-zero status).
How to Fix It
- Scroll up to the first error printed by the failing script,
ELIFECYCLEis usually the wrapper error. - Re-run just the failing script for clearer output (example:
npm run <script> -- --verbose). - Ensure required toolchain is installed (common: Python, C compiler toolchain,
make). - If this is in CI, compare environment variables and build dependencies with local.
Why It Happens
- A
postinstall/install/preparescript failed due to missing toolchain or environment. - A dependency build step failed (native addon compilation, missing Python, missing
make, etc.). - The script itself is failing with an application error.
How to Verify
- Re-run the failing script and confirm it exits 0.
- Re-run
npm installand confirm the lifecycle error is gone.
Manual debugging checklist
- Print scripts:
cat package.json | jq .scripts(or openpackage.json). - Check toolchain availability:
python --version,make --version,gcc --version(as applicable).
Common CLI Output
npm ERR! code ELIFECYCLEnpm ERR! Exit status 1npm ERR! command failednpm ERR! errno 1 How npm executes the command
- npm runs lifecycle scripts defined by packages during install.
- If any script exits non-zero, npm surfaces
ELIFECYCLEand stops the install.
Prevention Tips
- Keep build dependencies documented and installed on CI runners.
- Avoid heavy install-time scripts when possible, prefer build steps in CI.
- Pin Node/npm versions so script behavior stays consistent.
Where This Can Be Triggered
github.com/npm/cli/blob/39495d07b9a66c88621e8a2ad07739ee98b70a56/lib/utils/lifecycle.js
Open-source npm CLI code reference from v5.0.0 (legacy error code path). - GitHub
er.message = pkg._id + ' ' + stage + ': `' + cmd + '`\n' +
er.message
if (er.code !== 'EPERM') {
er.code = 'ELIFECYCLE'
}
fs.stat(npm.dir, function (statError, d) {
if (statError && statError.code === 'ENOENT' && npm.dir.split(path.sep).slice(-1)[0] === 'node_modules') {