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.
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# Check system logssudo dmesg | grep -i "killed process"# Or journalctljournalctl -k | grep -i oomnpm ERR! code ELIFECYCLEnpm ERR! errno 137
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.
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"
}
}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.