You deploy to Vercel and get a wall of red errors. Everything works perfectly on localhost.
This article covers the most common Vercel deployment errors organized by error type. Find your error message, understand the cause, and fix it fast.
Pre-Deploy Checklist
Run these three commands locally before every push. They catch most build errors before they reach Vercel.
npx tsc --noEmit # TypeScript type checking
npm run lint # ESLint check
npm run build # Production build
"Works in dev" and "passes build" are different things. Dev mode treats TypeScript errors as warnings. Build mode treats them as fatal errors.
Common oversights:
- Never running
npm run buildlocally before pushing - Environment variables available in
devbut missing inbuild - TypeScript
strictmode only activating in CI
Build Errors and How to Fix Them
Module not found
Error: Module not found: Can't resolve './Components/Header'
Cause: File name casing mismatch. macOS and Windows are case-insensitive, but Vercel (Linux) is case-sensitive.
Locally, import Header from './Components/Header' works even if the file is components/Header.tsx. On Vercel, it fails.
Fix:
# Enable case-sensitive git tracking (prevents future issues)
git config core.ignorecase false
Match your import paths exactly to the actual file names on disk.
Dependency resolution errors
npm ERR! Could not resolve dependency
Cause: package-lock.json or Node.js version mismatch between local and Vercel.
Fix:
- Vercel Dashboard → Settings → General → Node.js Version — match it to your local version
- Delete
package-lock.json, runnpm install, and recommit
Corrupted build cache
Build logs show bizarre errors and nothing has changed in your code.
Fix: Vercel Dashboard → Deployments → click "..." on the failed deploy → Redeploy without cache.
Works Locally, Fails on Vercel
The most frustrating pattern. The cause is almost always one of these three.
1. Writing to the file system
Error: EROFS: read-only file system, open '/var/task/data.json'
Serverless Function file systems are read-only. fs.writeFileSync works on your local Node.js server but fails on Vercel.
Fix: Use /tmp for temporary writes (500 MB limit). For persistent storage, use a database or object storage.
import { writeFileSync } from "fs";
import { join } from "path";
// NG: Read-only on Vercel
writeFileSync("./data.json", JSON.stringify(data));
// OK: /tmp is writable
writeFileSync(join("/tmp", "data.json"), JSON.stringify(data));
2. Missing environment variables
Environment variables in .env.local don't automatically sync to Vercel.
Fix: Vercel Dashboard → Settings → Environment Variables — add them manually. Make sure to check all three environments: Development, Preview, and Production.
3. Node.js version mismatch
Your local environment runs Node 22 while Vercel defaults to a different version, causing ES module resolution or API compatibility differences.
Fix: Vercel Dashboard → Settings → General → Node.js Version — match your local version. Or add a .node-version file to your project root.
Runtime Errors (500, Timeouts)
Build succeeds, but the site returns 500 or specific pages break after deployment.
Serverless Function has crashed
FUNCTION_INVOCATION_FAILED
Common causes:
- Uncaught exceptions (missing try/catch)
- Out of memory (Hobby plan: 2 GB limit)
- Environment variables missing, causing DB/API connection failures
Fix: Vercel Dashboard → Logs — check runtime logs for error details.
FUNCTION_INVOCATION_TIMEOUT
Task timed out after 10 seconds
Cause: With Fluid Compute disabled, Hobby plan's default timeout is 10 seconds. Fluid Compute is now enabled by default, extending the default to 300 seconds. But older projects or manually disabled settings may still have the 10-second limit.
FUNCTION_PAYLOAD_TOO_LARGE
FUNCTION_PAYLOAD_TOO_LARGE
The request body exceeds 4.5 MB. This hits file uploads or large JSON payloads.
Fix: For large files, use presigned URLs to upload directly to S3 or R2 instead of going through the serverless function.
When it's not your code: Vercel outages
Sometimes the error has nothing to do with your code.
On March 2, 2026, a Dubai region (dxb1) infrastructure failure blocked deployments for all Vercel users worldwide for 10+ hours. The cause was Vercel's architecture: Middleware deploys to all regions, so a single region failure prevented any Middleware-using project from deploying globally.
When deployments suddenly fail without any code changes:
- Check vercel-status.com first
- If it's a Vercel outage, there's nothing to do but wait
- After resolution, use Redeploy without cache
Environment Variable Gotchas
Environment variables are the most confusing part of Vercel deployments.
build-time vs runtime
Next.js has two types of environment variables.
| Type | Prefix | When read | After change |
|---|---|---|---|
| Server-side | None (DB_URL, etc.) | At request time (runtime) | Immediate |
| Client-side | NEXT_PUBLIC_ | Inlined at build time | Requires rebuild |
Common mistakes
Adding quotes in the dashboard:
# Wrong (in Vercel dashboard)
NEXT_PUBLIC_API_URL="https://api.example.com"
# Correct
NEXT_PUBLIC_API_URL=https://api.example.com
In Vercel's environment variable settings, quotes are not needed. Adding them makes the quotes part of the value.
Not checking Preview environment:
When adding environment variables, there are three checkboxes: Production, Preview, and Development. If Preview is unchecked, preview deployments (automatic deploys per PR) won't have access to the variable.
Know Your Plan Limits
Sometimes the error is just a plan limitation.
| Limit | Hobby (Free) | Pro ($20/month) |
|---|---|---|
| Function timeout | 300s (Fluid enabled) | 800s (Fluid enabled) |
| Memory limit | 2 GB | Up to 4 GB |
| Function size | 250 MB (unzipped) | 250 MB |
| Request body | 4.5 MB | 4.5 MB |
| Build time | 45 min | 45 min |
/tmp storage | 500 MB | 500 MB |
| Bandwidth | 100 GB/month | 1 TB/month |
| Fluid Active CPU | 4 hours/month | $20 credit offsets |
If you're hitting FUNCTION_INVOCATION_TIMEOUT frequently on Hobby, the 10-second limit is likely the cause. Enable Fluid Compute or optimize the function.
Wrapping Up
| Error | Check first |
|---|---|
| Module not found | Does the import casing match the actual file name? |
| Build failed | Does npm run build pass locally? |
| 500 error | Check Vercel Logs for runtime error details |
| Timeout | Enable Fluid Compute, optimize external API calls |
| Env vars not working | build-time vs runtime — which type are you using? |
| Sudden failure | Check vercel-status.com |
90% of "works locally, fails on Vercel" comes down to three things: case sensitivity, environment variables, and file system access. Remember these three and you'll solve most deployment errors quickly.
To prevent unexpected billing from Vercel's usage-based pricing, check out the Spend Management Guide.