Running my AOT build of my angular application failed with this error:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Using an NPM package to fix
Someone implemented an NPM package for this.
- install https://www.npmjs.com/package/increase-memory-limit globally
- run
increase-memory-limit
in the root of your project
Manual fix
- Navigate to
%appdata%
->npm
folder - Open
ng.cmd
in your favorite editor - Add
--max_old_space_size=8192
to the IF and ELSE block
My node.cmd
file looks like this after the change:
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
)