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.
<--- 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.
env:
NODE_OPTIONS: --max-old-space-size=4096Reduce build memory pressure
- Disable client source maps in production if not needed.
- Use a runner with more memory for the build job.
- Split or trim heavy dependencies pulled into the bundle.
export default defineNuxtConfig({
sourcemap: { client: false }
});How to prevent it
- Set
NODE_OPTIONS=--max-old-space-sizeto match the runner memory. - Disable unneeded source maps in production builds.
- Size the build runner for the app, not the smallest available.