Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install - javascript heap out of memory

When running npm install -g ionic I get the following error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Is there a way to globally increase the node.js memory limit?

like image 244
gunwin Avatar asked Oct 18 '16 15:10

gunwin


People also ask

How do I fix JavaScript out of memory?

To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. Alternatively, you can also set the memory limit for your entire environment using a configuration file.

Why JavaScript heap out of memory occurs?

js project is the “JavaScript heap out of memory” error. This error usually occurs when the default memory allocated by your system to Node. js is not enough to run a large project. The error is common whether you run your project on Windows, macOS, or a Linux distribution like Ubuntu.

How much memory does NPM install need?

Please reserve at least 6 GB for OS resources and npm On-Site appliance containers.

How do I fix a process out of memory in node JS?

This exception can be solved by increasing the default memory allocated to our program to the required memory by using the following command. Parameters: SPACE_REQD: Pass the increased memory space (in Megabytes).


1 Answers

You can launch NPM using :

node --max-old-space-size=8000 $(which npm) install -g ionic

As described here, the default is 4000 (4Gb).

like image 131
xShirase Avatar answered Oct 24 '22 04:10

xShirase