Vite "JavaScript heap out of memory" on Large App Builds in CI
A large vite build runs Rollup over thousands of modules, and the Node process can exhaust V8's heap on a constrained runner. It aborts with the same OOM as any other Node build.
What this error means
vite build dies with FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory, usually late in the production Rollup pass, on a runner with less RAM than your laptop.
vite
transforming...
✓ 3120 modules transformed.
rendering chunks...
<--- Last few GCs --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memoryCommon causes
Heap default too low for a big Rollup pass
Many modules, large source maps, and heavy chunking inflate peak memory beyond V8's default old-space cap.
Constrained CI runner
A small runner or container memory cap gives Node less RAM than the build peak, so it OOMs where a bigger machine would not.
How to fix it
Raise Node's heap and trim source maps
Give V8 more old-space and reduce source-map cost for the build.
Terminal
export NODE_OPTIONS=--max-old-space-size=4096
vite build
# vite.config.ts: build: { sourcemap: false } // or 'hidden' in CISplit chunks and lazy-load routes
- Use
build.rollupOptions.output.manualChunksto break up large vendor chunks. - Lazy-load routes/components so fewer modules render at once.
- Run the build on a larger runner for genuinely large apps.
How to prevent it
- Set a sensible
--max-old-space-sizefor the build job. - Trim source maps and split chunks to lower peak memory.
- Faster managed runners such as Latchkey offer more RAM plus dependency caching so large Vite builds complete under the heap ceiling and transient OOMs are auto-retried.
Related guides
webpack "JavaScript heap out of memory" - Fix Build OOM in CIFix webpack "FATAL ERROR: Reached heap limit ... JavaScript heap out of memory" during the build in CI - rais…
Vite "[vite]: Build failed with errors" - Diagnose the Real CauseFix Vite "[vite]: Build failed with errors" in CI - the wrapper message above a specific transform, resolve,…
esbuild "Transform failed with N errors" - Fix in CIFix esbuild "Transform failed with N errors" in CI - a syntax error, JSX in a non-JSX loader, or a wrong load…