I'm on a raspberry pi 4 with node V16.11.1. So I had this allocation fail error:
<--- Last few GCs --->
[9529:0x47e15e0] 63 ms: Mark-sweep 0.3 (2.8) -> 0.2 (2.8) MB, 3.5 / 0.0 ms (average mu = 0.242, current mu = 0.014) allocation failure GC in old space requested
[9529:0x47e15e0] 67 ms: Mark-sweep (reduce) 0.2 (2.8) -> 0.2 (1.8) MB, 3.4 / 0.0 ms (average mu = 0.144, current mu = 0.016) last resort GC in old space requested
[9529:0x47e15e0] 71 ms: Mark-sweep (reduce) 0.2 (1.8) -> 0.2 (1.8) MB, 3.7 / 0.0 ms (average mu = 0.079, current mu = 0.011) last resort GC in old space requested
<--- JS stacktrace --->
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Aborted
I search for solution, I tried:
node --max-old-space-size=4096 index.js
export NODE_OPTIONS=--max_old_space_size=4096
Nothing work and even when I try "npm" or "node file.js" which is a script with just console.log("test") and I have the same issue...
But with sudo node index.js it works but I think it's a problem with my node. I try to re-install but nothing change...