October 2024, This line fixed it:
export NODE_OPTIONS="--max-old-space-size=6144"
Just add this line to terminal, and if you got the same error replace 6144 with one of these options:
#increase to 7gb => 7168
#increase to 8gb => 8192