FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
V8 exposes method v8.getHeapStatistics() that returns an object.
Field heap_size_limit
contains the number of Bytes.
This value can be increased by setting --max-old-space-size option (in Mb). In example, to 8 Gb:
export NODE_OPTIONS='--max-old-space-size=8192'
npm run build
or
node --max-old-space-size=8192 index.js
However this might not help if the system has very little memory.
Check available memory by running free -m
command in Linux / MacOS shell.
Low available memory can be increased by enabling swap.