Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce NPM Memory use

I'm running npm install on a server and it's running out of memory. The server has 2GB of RAM, which is less than Node's default 4GB limit. I'm watching memory profiling and it's using all of the server's RAM before dying. I have a pretty small package.json file; we're talking around a dozen packages, and it seems pretty dumb to have to set up a swap just to do a handful of NPM installs.

Is there any way to get NPM to use less memory when running installs?

like image 644
Zags Avatar asked Aug 06 '26 04:08

Zags


1 Answers

The max_old_space_size option appears to fix this:

NODE_OPTIONS=--max_old_space_size=1000 npm install

like image 186
Zags Avatar answered Aug 07 '26 16:08

Zags



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!