Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'npm run build' often freezes my entire server

Tags:

reactjs

Perhaps 75-80% of the time, I can run git pull on my EC2 Linux server, then npm run build to create a production-ready build of my React app. On occasion, however, after running npm run build, the whole server freezes and I have to force restart several times just to get it up and running again.

It seems to be entirely random. It seems awfully bizarre some JavaScript compilation (I guess?) process can knock over an entire server, but it happens frequently enough that it's obviously not caused by anything else.

Is this something anyone's encountered?

like image 773
MitchEff Avatar asked Aug 06 '18 13:08

MitchEff


2 Answers

All this depends on the configuration of your server instance. Actually build process take a lot of processor power and memory ,so the server might reach out of memory while building.

You can consider upgrading your server Or one temporary solution for it can be that you can build the react app on your local machine and simply serve that build folder through the server.

like image 147
Yuvraj Mann Avatar answered Oct 18 '22 14:10

Yuvraj Mann


Build process in resource consuming, and this is exepected. This is why in my deploy pipelines often I launch the build locally before deploy (it takes about 6 minutes on some apps, depending on complexity and webpack configuration), or I setup another server that is only used for build process.

like image 26
Mosè Raguzzini Avatar answered Oct 18 '22 14:10

Mosè Raguzzini