How to fix npm ERR! code ELIFECYCLE npm ERR! errno 137 in npm
Exit code 137 indicates the process was killed by signal 9 (SIGKILL), usually by the OOM killer due to memory exhaustion. Increase available memory or optimize your build process.
Quick fix
Fixes npm ERR! code ELIFECYCLE npm ERR! errno 137
# Check system logs
sudo dmesg | grep -i "killed process"
# Or journalctl
journalctl -k | grep -i oom- Verify OOM kill
- Increase Node.js memory
- Increase container memory
- Reduce parallel operations
# Check system logssudo dmesg | grep -i "killed process"# Or journalctljournalctl -k | grep -i oomnpm ERR! code ELIFECYCLEnpm ERR! errno 137
What this error means
Exit code 137 is calculated as 128 + 9, where 9 is the signal number for SIGKILL. This signal is typically sent by the Linux OOM (Out of Memory) killer when a process consumes too much memory. Unlike other errors where the process chooses to exit, SIGKILL forcefully terminates the process. This commonly occurs during memory-intensive operations like webpack builds, Jest tests, or TypeScript compilation.
Typical symptoms
- npm script killed with exit code 137
- Process killed during build
- Build works locally but fails in CI/CD
- System becomes slow before error
- Container restarts unexpectedly
- dmesg shows OOM killer messages
Common causes
- Process exceeded memory limits
- OOM killer terminated process
- Container memory limit too low
- Large bundle size during build
- Memory leak in build tool
- Too many parallel processes
- Insufficient system RAM
How to fix "npm ERR! code ELIFECYCLE npm ERR! errno 137"
Check if OOM killer was responsible:
# Check system logs
sudo dmesg | grep -i "killed process"
# Or journalctl
journalctl -k | grep -i oomGive Node more heap:
export NODE_OPTIONS="--max-old-space-size=4096"
npm run buildOr in package.json:
"build": "node --max-old-space-size=4096 node_modules/.bin/webpack"For Docker/CI:
# Docker Compose
services:
build:
deploy:
resources:
limits:
memory: 4G
# GitHub Actions
jobs:
build:
runs-on: ubuntu-latest
# Consider larger runnerLimit concurrency:
# Jest
jest --maxWorkers=2
# Webpack
parallel: false
# npm
npm config set maxsockets 3Reduce memory usage:
// webpack.config.js
module.exports = {
optimization: {
minimize: false // for debugging
},
// Use incremental builds
cache: {
type: "filesystem"
}
};Break into smaller steps:
{
"scripts": {
"build:js": "webpack --config webpack.js.js",
"build:css": "webpack --config webpack.css.js",
"build": "npm run build:js && npm run build:css"
}
}Advanced notes
Exit code 137 can also occur from manual SIGKILL or container orchestration killing unresponsive containers. Monitor memory usage during builds with tools like htop or docker stats. In Kubernetes, set appropriate resource requests and limits. Consider using build caching to reduce repeated work. For very large projects, dedicated build machines may be necessary.
Frequently asked questions
- What does "npm ERR! code ELIFECYCLE npm ERR! errno 137" mean?
- Exit code 137 is calculated as 128 + 9, where 9 is the signal number for SIGKILL. This signal is typically sent by the Linux OOM (Out of Memory) killer when a process consumes too much memory. Unlike other errors where the process chooses to exit, SIGKILL forcefully terminates the process.
- How do I fix "npm ERR! code ELIFECYCLE npm ERR! errno 137"?
- Exit code 137 indicates the process was killed by signal 9 (SIGKILL), usually by the OOM killer due to memory exhaustion. Increase available memory or optimize your build process.
- What causes "npm ERR! code ELIFECYCLE npm ERR! errno 137"?
- Process exceeded memory limits OOM killer terminated process Container memory limit too low
- Is the "npm ERR! code ELIFECYCLE npm ERR! errno 137" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐
- ๐Docker Docs: resource_constraints(Official Docs)