Angular-cli AOT build fails with “FATAL ERROR: CAL

2019-07-18 05:09发布

问题:

I am trying to build my angular-cli project with AOT

ng build --aot

but it failes with error

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

The same thing happens if I build with the --prod flag.

Any idea?

回答1:

There is already an issue opened on github: https://github.com/angular/angular-cli/issues/5618

Meanwhile, as a workaround, you can try specifying the max_old_space_size setting (in MB)

node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --prod


回答2:

npm install

node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve