The ELIFECYCLE exit code 1 error indicates a npm script failed with an error. The actual error is typically shown before this message and relates to your script's code, not npm itself.
Fixes npm ERR! code ELIFECYCLE
# Error output is before this:
# npm ERR! code ELIFECYCLE
# The real error might be:
# SyntaxError: Unexpected token
# Error: Cannot find module
# Test failed: expected X got Y# Error output is before this:# npm ERR! code ELIFECYCLE# The real error might be:# SyntaxError: Unexpected token# Error: Cannot find module# Test failed: expected X got Ynpm ERR! code ELIFECYCLE
ELIFECYCLE occurs when a script in your package.json exits with a non-zero status. Exit code 1 is the general error code indicating something went wrong. npm is just reporting that your script failed - the actual problem is in your code or its dependencies. npm wraps all script execution and reports ELIFECYCLE when any script fails, regardless of the actual cause.
Look ABOVE the ELIFECYCLE message:
# Error output is before this:
# npm ERR! code ELIFECYCLE
# The real error might be:
# SyntaxError: Unexpected token
# Error: Cannot find module
# Test failed: expected X got YTest outside npm:
# See what the script runs
cat package.json | jq '.scripts.build'
# Run it directly
node build.js
# or
webpack --config webpack.config.jsEnsure all deps installed:
rm -rf node_modules
npm install
npm run your-scriptCheck required env vars:
# List required env vars from docs/code
env | grep -E "NODE_|API_|DB_"
# Set if missing
export NODE_ENV=developmentGet more information:
# Run with verbose
npm run build --verbose
# Or add to script
"build": "DEBUG=* node build.js"Address the specific issue:
- Syntax errors: check affected file
- Module not found: install missing package
- Test failures: fix failing tests
- Build errors: fix compilation issues
ELIFECYCLE is not the error itself - it's npm reporting that a script failed. Always look at the output before this message. In CI/CD, capture the full output to see the real error. Some tools have specific debug flags (DEBUG=*, --verbose, -v). Exit code 1 is generic; other codes may indicate specific problems.