Trying to deploy a react app on AWS EC2. I'm using apache so I got git clone under /var/www/html.
I didn't have any problem when I deployed other projects,
but when I npm install in this new project folder, within some seconds (when it's installing webpack), it just stuck at the same point with the same message.

It stuck there forever and any other command doesn't work. So I have to force quit the terminal. After that, I can't connect on my EC2 instance for 10 - 20min.
I tried npm install --verbose, removing package-lock.json, npm config set registry http://registry.npmjs.org/ --global, npm cache verify ... nothing worked.
It's really frustrating. I don't know what should I do. Any advice will be appreciated.
In my case, i had to create a swap file on my micro ec2 instance. My npm install hanged and was killed eventually. Once i increased the memory with the swap file, all worked fine!
Commands i used:
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo free -h
To make the swapfile persistent across reboots (run as root):
sudo echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
What type of EC2 instance are you using? check monitoring data, cpu usage and memory consumption in my experience, "npm install" hangs easily on an EC2 micro instance, if you have a lot of dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With