Node.js Diagnostic

Fix "JavaScript heap out of memory" in Node.js, Webpack, & Next.js Builds

The V8 JavaScript engine has a default memory ceiling (~2GB on 64-bit systems). Heavy tasks like compilation, large AST parsing, or data ingestion crash when exceeding this limit.

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Quick Fix Checklist

  1. Increase heap limit via NODE_OPTIONS: export NODE_OPTIONS="--max-old-space-size=4096"
  2. In package.json script: "build": "node --max-old-space-size=4096 node_modules/.bin/next build"
  3. Disable source-maps in production if memory is constrained (GENERATE_SOURCEMAP=false)