Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ec2 hangs on npm install

I have free tier ec2 (1GB RAB, 500MB swap memory)

When Jenkins performs npm install on the project, ec2 just hangs, stops responding and only reboot brings it to life.

With htop, I analysed the situation and figured out that RAM just exhausts and chokes and additional swap memory I created doesn't help.

Since I'm having a school project, I want to use free tier and somehow launch the project there (I tried npm run build too, but for now it has too many issues).

I tried yarn too, but there's an issue with different versions of babel-loader being required by two other packages.

Is there a way to perform npm install in an automatic fashion (so that Jenkins can do it with just a script shell) and without hanging ec2?

like image 644
Nikita Voloshenko Avatar asked Dec 09 '18 20:12

Nikita Voloshenko


People also ask

What to do if npm install hangs?

To solve the issue, try removing the entire node_modules/ folder and the package-lock. json file. Then try running the npm install command again. That may fix the issue.

Why is my EC2 instance stuck in the stopping state?

Instances might appear "stuck" in the stopping state when there is a problem with the underlying hardware hosting the instance. This can also occur when hibernating a hibernation-enabled instance. Note: To check the most recent state of your instance, choose the refresh icon in the Amazon EC2 console.

Why npm install is not working?

The main cause of the npm command not found error is that npm is not installed. You can run the command “npm -v” to check whether npm is installed. If not, I recommend you uninstall Node. js and then reinstall node.

What npm install does?

Description. This command installs a package and any packages that it depends on. If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock file, the installation of dependencies will be driven by that, respecting the following order of precedence: npm-shrinkwrap.json.


1 Answers

I ran into the same problem where the server just would stop installing. While it is definitely possible to upload the node_modules manually, I preferred to let npm do it for me. I solved it by deleting half of the dependencies before running npm install. After it finished i added them back and ran npm install a second time. Now everything is installed.
From now on npm install should work fine, since most dependencies are already installed. However adding or updating many dependencies at once might result in a hanging server again.

like image 183
Tomnar Avatar answered Sep 18 '22 15:09

Tomnar