Reduce NPM Memory use

Viewed 2894

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?

1 Answers

The max_old_space_size option appears to fix this:

NODE_OPTIONS=--max_old_space_size=1000; npm install

Related