Seeing npm install killed with exit code 137 usually means the Linux out-of-memory killer stopped it. Exit code 137 is 128 + 9: the process received SIGKILL. The same cause applies when pnpm install dies on a small machine.
This is common on 1 GB servers, such as a Google Cloud e2-micro. Confirm the cause first, then pick the smallest fix that works.
Table of contents

npm and pnpm unpack many packages and may run build scripts. On a machine with 1 GB of RAM and no swap, one heavy script can use all the memory. When RAM and swap are both full, the kernel’s out-of-memory (OOM) killer ends the largest process to keep the system alive.
Your terminal shows only the word Killed, with no stack trace. Because any SIGKILL gives exit code 137, check the kernel log before you change anything.
Look for a line in the kernel log that names the killed process. The dmesg manual page lists the options.
free -h
sudo dmesg -T | grep -i -E "out of memory|killed process"
sudo journalctl -k | grep -i -E "out of memory|killed process"
If the log shows node, npm or pnpm being killed, memory is the problem. If it shows nothing, something else sent the signal, for example a timeout or a manual kill.
Swap is the fastest fix on a machine with no swap at all. This creates a 2 GB swap file and keeps it after a reboot.
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
With swap in place, npm install killed errors usually stop, although the install runs slower. Swap on a small cloud disk is slow, so it prevents the kill but is not a replacement for enough memory.
Run the install without lifecycle scripts. If it succeeds, the spike comes from a post-install or build script rather than from downloading packages. The pnpm install documentation describes the option.
npm install --ignore-scripts
pnpm install --ignore-scripts
When npm install killed the process only during one script, that script is the one to fix. Run it on its own, with the options below or on a larger machine.
Setting a heap limit below what the machine can spare makes Node fail with a clear out-of-memory error instead of being killed silently. Pick a value that leaves room for the operating system. The Node.js command-line options page explains both the variable and the flag.
export NODE_OPTIONS=--max-old-space-size=512
Build in CI or on a larger instance and deploy only the output. Moving up one instance size is often cheaper than the time spent fighting a 1 GB machine.
Work through the fixes in the order below and stop at the first one that works. Confirming the cause is free, swap and skipping scripts take minutes, and a bigger machine is the last resort.

--ignore-scripts to find the heavy step.If the install runs inside docker build or a Kubernetes job, the limit may be the container’s memory limit rather than the VM’s. For the Kubernetes case, see Kubernetes OOMKilled: how to fix exit code 137.
No. Any SIGKILL gives 137, including kill -9. Check the kernel log to be sure.
The kernel ends the process with SIGKILL, which cannot be caught, so npm has no chance to print an error. The only trace is in the kernel log.
It usually stops the kill, but the install gets slower. If the machine is regularly short of memory, use a larger instance.
No. The OOM killer is part of the Linux kernel, so the same cause and checks apply on other distributions.
In short, npm install killed with exit code 137 is almost always a memory problem on a small machine. Confirm it in the kernel log, add swap, find the heavy script, and cap Node’s memory. If the machine is still too small, build elsewhere.
The Nandan Sinha newsletter
Get new articles on technology, practical guides, wellbeing and spirituality, delivered to your inbox.
Subscribe by email. Confirm your address to join. Unsubscribe anytime. Privacy policy.
We use essential cookies to run this website and optional cookies for analytics and advertising. Choose Accept All, Reject, or Preferences to manage optional cookies. You can change your choice at any time.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
These cookies are needed for adding comments on this website.
Google's current Sign in with Google client library. It renders the Google sign-in button, or the One Tap prompt, so visitors can log in to your site with their Google account. It replaces the older Google Sign-In platform library.
Service URL: policies.google.com (opens in a new window)
Google Tag Manager simplifies the management of marketing tags on your website without code changes.
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
Marketing cookies are used to follow visitors to websites. The intention is to show ads that are relevant and engaging to the individual user.
AddToAny provides share and follow buttons that let visitors post your pages to social networks, messaging apps, and bookmarking services.
Service URL: www.addtoany.com (opens in a new window)
You can find more information in our Privacy Policy and Privacy Policy.





Leave a Reply