Dealing with heap exhaustion while building Volto 17 on limited-RAM host

My 4 GB RAM virtual host has been hitting heap exhaustion when trying to build the Volto 17 (17.1.1 and 17.2.0) frontend image. Along the way other processes (including running Plone+Volto and Emacs) were terminated. I found a workaround that's simple and effective. Here are the details.

tldr: In the frontend package.json "scripts" "build" line, add "NODE_OPTIONS=--max-old-space-size=2048, changing the line to:

    "build": "NODE_OPTIONS=--max-old-space-size=2048 razzle build --noninteractive",


You'll know you have the problem if your frontend build-image fails with a stacktrace that includes this:

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

You may also see termination of incidental processes. (Omitting those other processes when building didn't keep my builds from failing.)

Here's the --max-old-space-size node.js documentation:
Command-line API | Node.js v21.1.0 Documentation (

I should add that I do have my system configured with some non-trivial additional swap, but that doesn't seem to really help (aside from lengthening the fail time while the system swaps frantically for a while). I tried plugging in various --max-old-space-size values and 2 GB was by far the best – the build goes smoothly and about as quickly as 16 did, without extraordinary system churn or disruption of other processes. Yay!

I'm curious whether others with systems that have limited memory are also encountering this behavior? If so, hope this info helps!


1 Like

Yes, I've encountered it, too. I've previously used the same option as you did, but now I build docker images on my machine and upload them to docker hub.

yes, ran into it myself, and I may at some point consider running Docker images ... but for now it's too much voodoo :wink:

I can take a hint. See Add warning of requirements to build Plone by stevepiercy · Pull Request #1558 · plone/documentation · GitHub. @klm I would @ on GitHub but I cannot find your username.

1 Like

You found me there. I am consistent in my username branding :slight_smile:

In case it's still useful, I'm @kenmanheimer on github.