I randomly get this error from time to time, and when i restart the server it works.
this error is only shown in this project, so i guess no issue related to the CLI itself.
Does anyone know what the potential cause of this issue ?, or to what is it related ?
as i believe it’s due to bad practices and the huge code size.
any suggestions to help reduce/fix this one ?
thank you in advance
This error happens when you don’t have enough memory to build your app:
I got this error on small server instance with only 1-2GB of RAM. I had to build my app locally and send the dist folder to my server via SSH to bypass the issue. You can also increase the memory size of the server to solve it.
In your case, as you mentioned you were on a local server with 16GB of RAM, it is more likely related with the Node.js memory limit.
The solution to run your
ng build with increased memory is to start the node process with an additional V8 flag: –max-old-space-size.
node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build