npm error code 137 or Killed during npm install or npm run build: what it means
Exit code 137 is 128 + 9: the process received SIGKILL, signal 9, which it cannot catch. During npm install or npm run build that is almost always the Linux out-of-memory killer, because the machine or the container's memory limit ran out. It is not Node's own heap limit, which prints FATAL ERROR ... JavaScript heap out of memory before it stops. Run fewer heavy steps at once, turn off production source maps, keep Node's heap below the container, or give the build more memory.
By Livops team, the people who build and run LivopsUpdated
One or more of these at the end of the log, with no stack trace and nothing from your own code just above them:
Killed
npm error code 137
npm error signal SIGKILL
npm ERR! code 137
This page explains where 137 comes from, how to tell it apart from Node’s own JavaScript heap out of memory, how to prove it was memory, and what to change, from the cheapest fix to buying more memory. Everything up to “On Livops” applies to any machine, CI runner or container.
What does exit code 137 mean?
It is a signal, not an error code from your program. When a command is ended by signal n, the shell reports its status as 128 + n[1]. 137 − 128 = 9, and signal 9 is SIGKILL[2]. SIGKILL cannot be caught, blocked or ignored[2], so neither Node nor npm gets to run any code after it: no error message, no stack trace, no cleanup. That is why the log simply stops.
Who sends SIGKILL during a build
Almost always the kernel’s out-of-memory (OOM) killer:
- In a container, memory is capped by the cgroup’s
memory.max. If the cgroup’s usage reaches that limit and can’t be reduced, the OOM killer is invoked inside the cgroup[3]. Docker says the same: by default, if an out-of-memory error occurs, the kernel kills processes in the container[5]. - On a whole machine, when the kernel cannot find memory for its own work, it starts killing processes to free some[5].
In both cases the kernel sends the chosen process SIGKILL[4]. The limit counts the cgroup “and its descendants”[3]: npm, the shell it starts, Node, esbuild, a type checker running beside the bundler. They share one budget, and the kernel picks one of them to kill.
The other senders of SIGKILL are people and tools: a kill -9, a CI system cancelling a job, a supervisor ending a step that ran too long. Those leave no out-of-memory trace (see below), so check before you start cutting memory. docker stop is one of them: it sends SIGTERM, then SIGKILL once the grace period runs out[17], so an app that ignores SIGTERM exits with 137 too. The fix then is to stop cleanly on SIGTERM, not to add memory.
What npm adds
npm runs a script through /bin/sh on Linux and macOS and cmd.exe on Windows[8]. When the script fails, npm’s error report lists its exit code, and the signal when the process died from one[9]: that is npm error code 137 or npm error signal SIGKILL, followed by command failed and the command. Newer npm writes these lines as npm error, older versions as npm ERR![10]; the meaning is the same. A bare Killed line comes from outside Node and npm as well, since neither can print anything after SIGKILL.
137 or heap out of memory: which one is it?
They are two different ceilings, and the last lines of the log say which one was hit:
| The log ends with | What stopped the process | The ceiling that was reached |
|---|---|---|
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory |
Node itself, before exiting | V8’s heap limit, set by --max-old-space-size[11] |
Killed, code 137, signal SIGKILL, and no FATAL ERROR |
The kernel, from outside | The memory of the container or the machine |
Node prints the first one itself when V8 reports that its heap is out of memory[12]; for that case see JavaScript heap out of memory, and for Next.js heap out of memory during next build.
The two are connected. Node’s heap limit is a ceiling inside one process; the container’s limit is a ceiling on everything in it. If Node is allowed a heap bigger than the memory the container can give, the kernel’s limit is reached first, and what would have been a readable heap error becomes a bare 137. This is the usual way people get here: they raise --max-old-space-size past the container’s memory to fix a heap error.
How to confirm it was memory
-
A container you ran.
docker inspectreportsOOMKilled: whether a process in the container was killed because it ran out of memory since the container last started[6].docker inspect my-build | grep OOMKilled -
Kubernetes.
kubectl get pod <pod>showsOOMKilledas the container’s last state when it was killed for memory[18].kubectl get pod my-pod -o yaml | grep -A3 lastState -
The kernel log on the host.
dmesgprints the kernel ring buffer[7]. The OOM killer writesOut of memory: Killed process <pid> (<name>)for the whole machine, andMemory cgroup out of memory: Killed process ...when a cgroup’s limit was the cause[4].dmesg -T | grep -i "killed process" -
From inside a cgroup v2 container.
memory.eventscountsoom_kill, the processes in the cgroup killed by an OOM killer, andmemory.peakis the most memory the cgroup has used[3]. With cgroup v2 they are usually under/sys/fs/cgroup:cat /sys/fs/cgroup/memory.events /sys/fs/cgroup/memory.peak
On a hosted CI runner or a platform you usually cannot read the host’s kernel log. Then the evidence is the shape of the log: 137 or Killed, no FATAL ERROR, at the step that uses the most memory, and a local run under the same limit (below) that fails the same way.
Fixes, cheapest first
1. Don’t run heavy steps at the same time
A build script that starts the type checker and the bundler together, or a monorepo tool that builds several packages in parallel, runs several Node processes inside one memory limit[3]. Run them one after another:
{
"scripts": {
"build": "tsc --noEmit && vite build"
}
}
The same holds for plugins that move work to a separate process. webpack’s guide suggests fork-ts-checker-webpack-plugin to run type checking in its own process[15]: that makes the build faster, but the extra process still counts against the same container.
2. Turn off production source maps
Source maps cost memory and time while they are generated.
- webpack: its guide says source maps are “really expensive”[15].
devtool: falseemits none, and the docs call it a good option to start with in production[14]. - Create React App:
GENERATE_SOURCEMAP=falsestops source maps in the production build, and the docs name this as a fix for out-of-memory problems on smaller machines[13]. - Vite:
build.sourcemapisfalseby default[16]; if your config turns it on, try the build without it. - Next.js: see heap out of memory during next build.
3. Give Node a heap limit that fits inside the container
Set the heap below the memory the build really has, so that Node, not the kernel, reaches its limit first. Node’s docs suggest 1536 MiB on a machine with 2 GiB, to leave memory for other uses[11]:
NODE_OPTIONS=--max-old-space-size=1536 npm run build
This does not make the build need less. It changes how it fails: if the Node heap is the problem, you now get JavaScript heap out of memory naming the step, instead of a silent 137. If 137 still happens with the heap capped, the memory is going somewhere other than one Node heap: parallel processes, native tools, or npm install itself.
4. When npm install is the step that dies
Look at what the install was doing when it stopped. If it was compiling a native module from source, see node-gyp rebuild failed: a package with a prebuilt binary skips the compile entirely. Keep the install and the build as separate steps, so the peak is one or the other, not both.
5. When it truly needs more memory
If the build’s peak is still above the limit after the steps above, raise the limit. Measure the peak first (memory.peak above[3]), then:
- Docker:
-m/--memoryis the most memory the container can use[5]. If--memoryis set and--memory-swapis not, the container can also use as much swap as its memory setting, when the host has swap[5]: a build that swaps survives, slowly. - CI: choose a larger runner.
- A platform: a bigger build or plan; see the Livops section below.
How to reproduce it locally
Run the build under the same limit as the server. On a laptop with plenty of memory it passes; inside a container with -m it fails the same way:
docker run --rm -m 2g -v "$PWD":/app -w /app node:22 \
sh -c "npm ci && npm run build"
echo $?
137 there confirms the diagnosis. Then try the fixes one at a time until it passes with room to spare.
On Livops
- The build’s memory is in the first line of the log. The build log starts with
Build server: <region> · <n> cores, <memory>: that is the ceiling for one build step. For a project built from its ownDockerfile, the line states that build’s ceiling. - Node’s heap is set to fit it. For a framework build (not your own
Dockerfile), every install and build step runs withNODE_OPTIONS=--max-old-space-sizeset to three quarters of the build container’s memory, leaving the rest for esbuild, native modules and the shell. A Node process that outgrows the build then reportsJavaScript heap out of memoryand names the step, instead of being killed with nothing printed. If you setNODE_OPTIONSin Variables, Livops leaves it alone; keep your value below the ceiling the first line states. In your ownDockerfile, Livops sets nothing: put it on theRUNline yourself. - A Tip when it runs out. When a build step is killed with exit status 137, or prints
JavaScript heap out of memory, the log ends with:Tip: the build ran out of memory. For a Node build set NODE_OPTIONS=--max-old-space-size=2048 in the variables and turn off source maps in production (GENERATE_SOURCEMAP=false, productionBrowserSourceMaps: false); if it still does not fit, write to us for a bigger build.The deploy fails at that step, and the previous version keeps running. - A running app that hits 137. An app that uses more memory than its plan allows is stopped, and the log says
Killedor exit code 137. Choose a bigger memory tier in the settings or make the app use less. The tiers are 256, 512, 1024, 2048, 3072 and 4096 MiB;memoryinlivops.jsonsets it when the project is created, and the settings change it after that. A Node app’s heap limit is not set for you at run time: addNODE_OPTIONSin Variables, below the tier. Two causes look the same: the app needs more than the tier (a large model, a big cache, several workers), or it leaks. Watch memory after a restart: flat near the limit from the start means it needs more; a steady climb until the kill means a leak, and a bigger tier only makes the cycle longer. - The assistant offers the bigger tier. Write “out of memory” or “exit code 137” about a project in the cabinet or in Telegram, and the assistant offers the next memory size as a button.
- See the memory over time. Through the Livops MCP server,
get_metricsreturns a service’s CPU, memory and traffic for 1 hour, 24 hours or 7 days, enough to tell a steady climb from one spike.
{
"memory": 1024
}
More in the docs: The build ran out of memory, Out of memory and Frameworks and livops.json.
Questions
What does exit code 137 mean?
128 + 9. A shell reports 128 plus the signal number when a command is ended by a signal, and signal 9 is SIGKILL. SIGKILL cannot be caught, so the process had no chance to print anything. During a build it is almost always the out-of-memory killer.
Is exit code 137 the same as JavaScript heap out of memory?
No. Heap out of memory is Node stopping itself because V8's heap reached its limit, and it prints FATAL ERROR first. Exit code 137 is the kernel killing the process from outside because the machine or container ran out, with no message from Node. A heap limit set above the container's memory turns the first into the second.
How do I prove it was memory and not something else?
For a Docker container, docker inspect shows OOMKilled true. On the host, the kernel log has a line like Out of memory: Killed process, or Memory cgroup out of memory: Killed process for a container limit. In a cgroup v2 container, the oom_kill count in memory.events goes up. A cancelled CI job or a kill -9 also gives 137, without those traces.
Is exit code 137 always out of memory?
No. Anything that sends SIGKILL gives 137: kill -9, a cancelled CI job, or docker stop when the app ignores SIGTERM and the grace period runs out. Check OOMKilled in docker inspect, or in Kubernetes the pod's last state, before you tune memory.
Will adding swap fix it?
It can keep the build alive, slower. Docker lets a container with a memory limit use as much swap as its memory setting when the host has swap configured and memory-swap is not set. Many CI runners and platforms have no swap at all, so the reliable fixes are using less memory or getting more.
Why does the build pass on my laptop and fail in CI or Docker?
Your laptop has more memory than the runner or the container's limit, and nothing kills the build there. Run the build locally under the same limit with docker run -m to see the 137 on your machine, then cut what the build holds.
How much memory does a Livops build get?
The first line of the build log says it: Build server, the region, the cores and the memory. For a framework build Livops sets Node's heap to three quarters of that, unless you set NODE_OPTIONS yourself, so a Node process that outgrows it usually stops with heap out of memory instead of a bare 137. If it still does not fit, write to Livops for a bigger build.
Sources
- bash(1) — Linux manual page (Simple Commands, exit status) (man7.org). Checked .
- signal(7) — Linux manual page (man7.org). Checked .
- Linux kernel docs — Control Group v2 (memory controller) (docs.kernel.org). Checked .
- Linux source — mm/oom_kill.c (raw.githubusercontent.com). Checked .
- Docker docs — Resource constraints (docs.docker.com). Checked .
- Docker Engine API — ContainerState (moby api/swagger.yaml) (raw.githubusercontent.com). Checked .
- dmesg(1) — Linux manual page (man7.org). Checked .
- npm docs — npm run-script (docs.npmjs.com). Checked .
- npm CLI source — lib/utils/error-message.js (raw.githubusercontent.com). Checked .
- npm CLI — pull request 7414, log prefixes use the level name (github.com). Checked .
- Node.js docs — Command-line API (nodejs.org). Checked .
- Node.js source — src/node_errors.cc (raw.githubusercontent.com). Checked .
- Create React App — Advanced configuration (create-react-app.dev). Checked .
- webpack — devtool (webpack.js.org). Checked .
- webpack — Build performance (webpack.js.org). Checked .
- Vite — Build options (vite.dev). Checked .
- Docker docs — docker container stop (docs.docker.com). Checked .
- Kubernetes — Assign Memory Resources to Containers and Pods (kubernetes.io). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your Node appRelated
- FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory: how to fix itNode stopped itself because V8's JavaScript heap reached its limit. Raise the limit with NODE_OPTIONS=--max-old-space-size, always below the memory the machine or container really has, then cut what the process holds: source maps and type checking in a Vite, webpack or tsc build, or the leak in a server that grows until it crashes. Set above the container's memory, the same problem comes back as exit code 137.
- JavaScript heap out of memory during next build: how to fix itNode's JavaScript heap reached its limit while Next.js was building, and V8 stopped the process. Raise the heap limit with NODE_OPTIONS=--max-old-space-size, staying below the memory the build really has, and cut what the build holds in memory: source maps, type checking during the build, and heavy dependencies.
- npm failed with return code 1 (npm ERR! code 1): how to fix the buildnpm failed with return code 1, or npm install exited with 1, is npm ERR! code 1 in newer npm: it only says that a script npm ran exited with code 1. The real error is printed above it: usually a compile or type error, a lockfile out of sync with package.json, or a dependency whose install script failed. Find the first error line above code 1, fix that, and the build passes.
- gyp ERR! build error / gyp ERR! find Python: node-gyp rebuild failed during npm install, how to fix itgyp ERR! build error, gyp ERR! find Python or gyp ERR! stack Error: not found: make means npm install tried to compile a native addon such as bcrypt, sqlite3 or sharp, and the machine has no Python, make or C++ compiler. It usually happens because no prebuilt binary fits your Node version or platform (Alpine/musl included). Upgrade to a release with prebuilt binaries, switch to a pure-JavaScript package such as bcryptjs, or install the build tools.
- Gunicorn [CRITICAL] WORKER TIMEOUT: what it means and how to fix itGunicorn's master killed a worker that sent no heartbeat for longer than --timeout, 30 seconds by default. With the default sync worker that means one request ran too long. Move the slow work out of the request, use gthread workers for slow I/O, load heavy models at start with --preload instead of in the first request, and raise --timeout only for the app that needs it.
- Docker hosting: how to deploy a Docker container or a DockerfileTo host a container you need a host that builds or pulls the image, starts its CMD, sends traffic to the port it listens on and stops it with SIGTERM. On Livops a Dockerfile at the root of the repository is built on Livops's servers and runs for 39 credits a month (39,000 so'm); a public image from Docker Hub, GHCR or Quay runs without a build. Here is what a container needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.
- Node.js hosting in 2026: how to deploy an Express appA Node.js server in production needs one long-running process that listens on the port it is given, restarts when it crashes and exits cleanly on SIGTERM. On Livops you push a repository with package.json and it runs as a web app for 39 credits a month (39,000 so'm). Here is what Node needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.