Skip to content
Latchkey

Nuxt "JavaScript heap out of memory" during build in CI

Node's V8 heap has a default ceiling. A large Nuxt build (many pages, big dependencies, source maps) can exceed it on a CI runner with limited memory, and the process aborts with a heap allocation failure.

What this error means

nuxt build fails with "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory" and a V8 stack trace. It builds locally where more memory is available.

nuxt
<--- Last few GCs --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb... node::Abort()
 2: 0xc... v8::internal::Heap::FatalProcessOutOfMemory(...)

Common causes

The build exceeds the default V8 heap

Bundling a large app with source maps and many modules needs more memory than Node allocates by default on the runner.

A memory-constrained runner

A smaller CI runner has less RAM than a developer machine, so the same build that passes locally hits the limit.

How to fix it

Raise the Node heap limit

Increase --max-old-space-size so V8 can use more of the runner's memory.

.github/workflows/ci.yml
env:
  NODE_OPTIONS: --max-old-space-size=4096

Reduce build memory pressure

  1. Disable client source maps in production if not needed.
  2. Use a runner with more memory for the build job.
  3. Split or trim heavy dependencies pulled into the bundle.
nuxt.config.ts
export default defineNuxtConfig({
  sourcemap: { client: false }
});

How to prevent it

  • Set NODE_OPTIONS=--max-old-space-size to match the runner memory.
  • Disable unneeded source maps in production builds.
  • Size the build runner for the app, not the smallest available.

Frequently asked questions

What causes ""JavaScript heap out of memory""?
Bundling a large app with source maps and many modules needs more memory than Node allocates by default on the runner.
How do I fix "JavaScript heap out of memory"?
Increase --max-old-space-size so V8 can use more of the runner's memory.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card