Encountering an error in my Angular application on Windows10 when using ng build --prod
, but it works fine with ng build
.
The issue seems to arise from the presence of 4 JSON files in the assets folder, with one file being 21 MB and the others ranging from 4-5 MB. Removing the 21MB file resolves the problem.
PS D:\ProjectPath\Project1> ng build --prod
Option "extractCss" is deprecated: Deprecated since version 11.0. No longer required to disable CSS extraction for HMR.
⠏ Generating browser application bundles (phase: building)...
<--- Last few GCs --->
[17748:00000150A9FB1CE0] 191749 ms: Mark-sweep 2033.1 (2052.3) -> 2032.4 (2053.3) MB, 1579.1 / 0.1 ms (average mu = 0.135, current mu = 0.011) allocation failure scavenge might not succeed
[17748:00000150A9FB1CE0] 194133 ms: Mark-sweep 2034.3 (2053.3) -> 2032.9 (2053.1) MB, 2361.8 / 0.1 ms (average mu = 0.063, current mu = 0.009) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
[FATAL ERROR]: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
...
Here's a snippet from my Angular.json
file:
{
...
}
And here's a part of my package.json
file:
{
...
}
I have tried various solutions mentioned in this Stack Overflow post as well as utilizing the package increase-memory-limit. Running
setx NODE_OPTIONS --max_old_space_size=10240
in cmd did not resolve the issue.
Angular CLI: 10.0.5 Node: 12.18.3 OS: win32 x64
Any suggestions on how to address this?