Skip to content
Docs

JavaScript heap out of memory in a build

A build on Tanzahost has 2 GB of memory. Give Node.js more of it in the build command, or raise your app's memory limit above 2 GB for bigger builds.

Updated 22 Oct 20262 min read

The whole message:

text
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

The fix on Tanzahost: let Node.js use more of the build's memory. Open the app. Under Build and run, set the Build command to your build with a bigger heap, then choose Save and build:

Terminal
NODE_OPTIONS=--max-old-space-size=1536 npm run build

1536 is in megabytes. It leaves room under the build's 2 GB for everything else the build runs. Use pnpm run build or yarn run build if that's your tool.

Setting it in the build command, rather than as a variable, keeps it out of your running app. A running app has its own memory limit, often much smaller, and a heap bigger than that limit gets the app stopped instead of failing gently.

Why it happens

Node.js gives its JavaScript heap a ceiling of its own, often below all the memory it was given. Big builds, like Next.js with many pages or a large Vite bundle, can pass it. Node.js then stops with this message, usually after lines like Ineffective mark-compacts near heap limit, and our build log ends with "The command "npm run build" stopped with code …".

Every build on Tanzahost runs in its own sandbox with these limits:

LimitValue
Memory2 GB, or your app's memory limit if that's higher, up to 16 GB
Processors2
Time15 minutes

If 2 GB isn't enough

Raise your app's memory limit above 2 GB under Limits, and the build gets as much. A limit costs nothing by itself: your app still pays only for the memory it really uses, hour by hour. Then raise --max-old-space-size to match, leaving about 500 MB spare, like 3584 for a 4 GB limit.

Before that, it's worth checking why the build needs so much. Source maps for production, a huge icon library imported whole, and type checking inside the build are the usual reasons.

How to check

  1. Open the build's log. The last lines show Node.js's message and the step that ran out, like npm run build.

  2. If the log ends with "The build took longer than 15 minutes, and was stopped." instead, it's the time limit, not memory.