Long build time on vercel or github actions
As per the title. I have incredibly long build times. Locally it takes about 3minutes.
on vercel after 15 minutes it goes out of memory.
It's a rather large project (nuxt 3). Not sure how to start optimising this? I analyzed the bundle but nothing too strange there.

3 Replies
Hi @Hro. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Long build times and out-of-memory errors on platforms like Vercel or GitHub Actions are common issues for large Nuxt 3 projects. Based on the knowledge sources, here are some concrete steps and considerations:
1. Nitro Build Time: In Nuxt 4 (and Nuxt 3 with Nitro), most of the build time can be spent in the Nitro server build, not the Vite client/server build. In one reported case, Vite builds took only 10–15 seconds, but the overall build was over 7 minutes due to Nitro. This suggests that optimizing Nitro or reducing the number of server routes/files can help. There was also a known Nitro regression that caused slow builds, so ensure you are on the latest Nitro version and check for related issues or updates Nuxt 4 takes more 7 minutes to build locally.
2. Memory Usage: Out-of-memory errors can be caused by large bundles, too many files, or memory leaks in dependencies. One user suspected the Nuxt UI module as a cause for memory issues FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory. Try disabling or updating heavy modules to see if it helps.
3. Build Cache: There is a community module (
nuxt-build-cache
) that can cache parts of the build to speed up subsequent builds, especially useful for CI/CD environments. This can significantly reduce build times if only data or server routes change. See the video for more details: Faster Nuxt Builds? 🤔 No problem ✅.
4. Prerender Optimization: If you are prerendering many pages, use the sharedPrerenderData
feature (introduced in Nuxt 3.10) to avoid duplicate data fetching and speed up builds. This is especially helpful for content-heavy sites Nuxt 3.10 - Speed up your build time with sharedPrerenderData.
5. Upgrade Dependencies: Sometimes, slow builds are caused by regressions or bugs in Nuxt, Nitro, or related modules. Upgrade dependencies one by one to identify if a particular package is causing the slowdown Nuxt 4 takes more 7 minutes to build locally.
6. Analyze and Reduce Bundle Size: Even if your bundle analysis looks fine, check for large assets (like fonts or images) being bundled, as seen in the logs with large .ttf
files. Move such assets to a CDN or load them dynamically if possible.
7. CI/CD Resource Limits: Vercel and GitHub Actions have memory and CPU limits. If your build works locally but fails in CI, try increasing the memory limit (if possible) or splitting the build into smaller steps.
Summary of Actions:
- Update Nuxt, Nitro, and all modules to the latest versions.
- Try the nuxt-build-cache
module for faster CI builds.
- Use sharedPrerenderData
if prerendering many pages.
- Remove or update heavy modules (like Nuxt UI) if suspected.
- Check for large static assets in your bundle.
- If possible, increase memory limits in your CI environment.
If you need more targeted help, try to isolate which part of the build (client, server, Nitro) is slow or failing, and share logs for further diagnosis.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@385142776674910238> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
legacy externals dropped it locally from 3min to 1min30..
still fails on vercel tho