The npm SIGKILL error occurs when the operating system forcibly terminates the npm process, typically due to out-of-memory conditions, container resource limits, or CI/CD timeouts. Unlike SIGTERM, SIGKILL cannot be caught or handled.
The SIGKILL signal (signal 9) is an unconditional, forced termination signal sent by the operating system to immediately kill a process. Unlike SIGTERM which allows graceful shutdown, SIGKILL cannot be caught, ignored, or handled by the application—it terminates the process instantly without cleanup. When npm receives SIGKILL during installation or build operations, it indicates that something external to npm itself (the Linux kernel's OOM killer, a container orchestrator, a CI/CD system, or manual intervention) has forcibly terminated the process. This is almost never a problem with npm itself, but rather a symptom of resource constraints, timeout policies, or system-level process management decisions in your environment. The exit code 137 (128 + 9 for SIGKILL) is a reliable indicator that the process was killed by SIGKILL rather than exiting normally.
The first diagnostic step is to verify whether the Linux OOM killer was responsible:
# On Linux, check kernel logs
dmesg | grep -i 'out of memory\|killed process\|oom-kill'
# Or check syslog
grep -i 'oom-kill\|out of memory' /var/log/syslog
# In Docker, check container logs
docker logs <container-id> 2>&1 | grep -i killedIf you see messages like "Out of memory: Kill process npm", the OOM killer is the culprit.
Expand the memory available to npm by allocating more RAM to your container or system.
For Docker containers:
# docker-compose.yml
services:
app:
image: node:18
mem_limit: 2g
memswap_limit: 4g # Total memory + swapOr via command line:
docker run -m 2g --memory-swap 4g node:18 npm installFor Linux systems with no swap:
# Create 2GB swap file
sudo dd if=/dev/zero of=/var/swap.1 bs=1M count=2048
sudo chmod 600 /var/swap.1
sudo mkswap /var/swap.1
sudo swapon /var/swap.1Reduce memory consumption during npm operations:
# Deduplicate dependencies
npm dedupe
# Check for outdated packages
npm outdated
npm update
# Remove node_modules and reinstall cleanly
rm -rf node_modules package-lock.json
npm installLimit Node.js heap size explicitly during build:
NODE_OPTIONS="--max-old-space-size=2048" npm run buildnpm is not a process manager and doesn't properly relay signals to child processes.
In Dockerfile, replace npm with direct node execution:
# WRONG - npm won't relay signals properly
CMD ["npm", "start"]
# CORRECT - node handles signals directly
CMD ["node", "server.js"]This ensures the Node process is PID 1 and receives signals directly from the system.
If SIGKILL occurs after a fixed time period, your CI/CD system is likely enforcing a timeout.
GitHub Actions:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- run: npm installGitLab CI:
build:
script:
- npm install
timeout: 2 hoursIf increasing memory doesn't help, there may be a memory leak in your build process:
# Monitor memory usage during npm install
watch -n 1 'ps aux | grep node | grep -v grep'
# For Docker builds, watch memory in real-time
docker stats <container-id>
# Add debug logging
node --trace-gc npm run build 2>&1 | tee build.logLook for memory continuously increasing without recovery.
Exit Code 137: When SIGKILL terminates a process, the exit code is 128 + 9 (signal number) = 137. This is different from normal failure codes and is a reliable indicator of SIGKILL.
Signal Handling Difference: SIGTERM (signal 15) allows graceful shutdown with a grace period (Kubernetes: 30 seconds, Docker: 10 seconds default). SIGKILL is always immediate—there's no opportunity for cleanup.
Container vs. System: In containerized environments, the container may have its own OOM killer separate from the host system. Setting memory limits in Docker creates cgroups that have their own OOM killer behavior.
Node.js Heap Size: The --max-old-space-size flag limits Node's garbage collection behavior, not actual system memory. A process can still be killed by the system OOM killer even if Node believes it has memory available.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error