[Solved] FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of me

Build react project prompts error message


<--- Last few GCs --->

[1118:0x104c00000]   210060 ms: Scavenge (reduce) 2020.9 (2049.8) -> 2020.1 (2051.3) MB, 3.4/0.0 ms  (average mu = 0.148, current mu = 0.006) allocation failure 
[1118:0x104c00000]   213180 ms: Mark-sweep (reduce) 2021.0 (2050.3) -> 2020.1 (2051.3) MB, 3117.6/0.0 ms  (average mu = 0.089, current mu = 0.010) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x101319fc5 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x1000b6169 node::Abort() [/usr/local/bin/node]
 3: 0x1000b62df node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x100200ba7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x100200b43 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]

Solution:

1. Install increase-memory-limit.

 npm install -g increase-memory-limit

2. Execute after successful installation

increase-memory-limit

Execute npm run build again and it will be OK!

Read More: