node --max-old-space-size: Fix Heap OOM
V8 caps the old-space heap; large builds can exceed it and crash.
"JavaScript heap out of memory" in CI usually means the build needs more heap than V8’s default. Raise it via NODE_OPTIONS, but make sure the runner actually has the RAM.
Common usage
--max-old-space-size=4096- 4 GB heap (MB)- set globally:
NODE_OPTIONS=--max-old-space-size=4096 - must be <= the runner’s physical RAM
Example in CI
Give the build more heap.
shell
NODE_OPTIONS=--max-old-space-size=4096 npm run buildIn CI
Raising the heap above available RAM just trades a V8 OOM for an OS OOM-kill (exit 137). Right-size the runner. Managed runners like Latchkey offer larger-RAM options and auto-retry transient OOM-kills.
Key takeaways
- Raise heap via
NODE_OPTIONS. - Heap must fit the runner’s RAM.
- Too high trades V8 OOM for exit 137.