Reputation: 133
Angular2 cli Project Production Build [ng build -prod] getting struck on 92% and getting error message like, running out of heap memory. Is there any solution for it? Project consists of huge number of components. Normal build is working fine [ng build]
Thank you
Upvotes: 5
Views: 4945
Reputation: 413
If you are working with a Node Version >= 8, you can use the solution posted in Node.js heap out of memory:
In your package.json file, replace ng build xxx
with node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build xxx
The value 8192 is the space in MB which node and angular as well will be allowed to use
Upvotes: 0
Reputation: 1750
Please check the version of Angular CLI, If its 1.2.6 downgrade it to 1.2.1. It will work. I too have the same issue and solved by this mean. NB: it's only a temporary fix. Hope cli team will solve the issue ASAP.
Upvotes: -1
Reputation: 214017
There is only one workaround today.
Open ./node_modules/.bin/ng.cmd
and add --max_old_space_size
option
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
)
Or you can upgrade your computer:)
Related issue on github
Upvotes: 3