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
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.