ProjectStack
npm

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed — JavaScript heap out of memory

Node.js ran out of memory while running your program. The default heap size is around 1.5GB, which can be exceeded by large builds, data processing, or memory leaks.

Common causes

  • Building a large application with webpack or other bundlers that process many modules
  • A memory leak — objects are being created but never garbage collected
  • Processing large data files or arrays in memory all at once
  • Running Node.js in a container with very limited memory allocation

How to fix it

  1. Increase the Node.js memory limit: NODE_OPTIONS='--max-old-space-size=4096' npm run build
  2. Add it permanently to your npm script: "build": "node --max-old-space-size=4096 node_modules/.bin/webpack"
  3. Profile memory usage to find leaks: node --inspect index.js and use Chrome DevTools
  4. Process large data in streams or chunks instead of loading everything into memory

Example

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory <--- Last few GCs ---> [12345:0x...] Scavenge (reduce) 1500.0 / 1500.0 ms

Running npm run build on a large Next.js or webpack application without increasing the memory limit

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.