zaq zaq - 1 month ago 9
Node.js Question

AWS EC2 : Ubuntu Webserver - Process out of memory when running npm install

I have been running an instance on AWS EC2 (Ubuntu Webserver) just fine for last couple of weeks. Recently, I tried to update my application and thus tried to install all

npm packages
again and restart my application.

However, I am running into out of memory problem whenever I run
npm install


I have killed all
screen
process and also tried
killall node


Is there any command I can use to free up some memory space for my EC2 instance?

Following is the error I am receiving when running
npm install


enter image description here

I am using 2 disk volumes for my ES2 instances (8GB each). The first disk space holds the OS and second one holds my actual application.

enter image description here

Answer

You don't say what type of instance you're using, but I have seen this on occasion on t2.nano and t2.micro instances.

If that is the case, you have two options: you can move to a larger instance type, or you can add virtual memory by configuring swap space. If the application runs fine, and you only see this when running npm, then adding swap might fix the issue. The t2 family doesn't have instance storage, so you're have to add swap on one of your EBS volumes (if you have space) or on an additional volume.

Comments