Angular Production Build is taking about 1.5 GB of memory and still runs Out Of Memory

Viewed 4422

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]

Screenshot

Thank you

3 Answers

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

Related