- Published on
Fixing Vercel "No Serverless Pages Were Built" Out of Memory Error
- Authors
- Name
- Avasdream
- @avasdream_
Fixing Vercel's "No Serverless Pages Were Built" Memory Error
Deploying a Next.js application to Vercel should be seamless, but sometimes you'll encounter this frustrating error:
Error: No serverless pages were built
• At least one "Out of Memory" ("OOM") event was detected during the build.
This error occurs when your build process exceeds the available memory in Vercel's build container, causing the build to fail just before completion. Here's how to fix it.
Quick Solution: Enable Enhanced Builds
The fastest solution is to upgrade your build infrastructure:
- Go to your Vercel project dashboard
- Navigate to Settings → General → Build & Development Settings
- Toggle ON "Enhanced Build Infrastructure"
- Redeploy your project
Enhanced Builds provide more memory and processing power, which is often all you need for memory-intensive builds.
Additional Optimizations
If you need to optimize further or can't use Enhanced Builds, try these solutions:
1. Add Memory Flags to Your Build
Update your package.json
build script:
{ "scripts": { "build": "NODE_OPTIONS='--max-old-space-size=6144' next build" } }
vercel.json
Configuration
2. Create a Add build environment variables:
{ "build": { "env": { "NODE_OPTIONS": "--max-old-space-size=6144" } } }
3. Optimize Your Next.js Configuration
Update next.config.js
to reduce memory usage:
module.exports = {
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
swcMinify: true,
}
Why This Happens
Memory-intensive builds typically occur when using:
- Multiple build plugins (Contentlayer, Prisma, etc.)
- Large static site generation
- Complex webpack configurations
- Heavy dependencies like CMS integrations
The default Vercel build container has 8GB of memory, which may not be sufficient for complex applications.
Prevention Tips
- Clean dependencies regularly: Run
yarn dedupe
ornpm dedupe
- Update packages: Keep dependencies current to benefit from performance improvements
- Monitor build times: Long builds (>5 minutes) often indicate memory issues
- Split heavy operations: Move non-critical tasks from build-time to runtime
Enhanced Builds Cost Considerations
While Enhanced Builds is the quickest fix, it's worth understanding the pricing impact. Enhanced Builds provide double the resources (8 vCPU, 16GB RAM vs 4 vCPU, 8GB RAM) and cost approximately 2x per build minute. For Pro teams, this means paying an additional $0.012-0.016 per minute, depending on your concurrency tier. However, Vercel reports that Enhanced Builds are 25% faster on average, which can partially offset the increased per-minute cost through reduced total build time. This feature is only available on Pro and Enterprise plans – Hobby users will need to optimize their builds using the techniques above or upgrade their plan.
By implementing these changes, you should be able to deploy successfully. Enhanced Builds is usually the quickest fix, but the optimization techniques will help ensure efficient builds regardless of your infrastructure tier.
Happy deploying! 🚀