Fix Next.js 16 Compile Stuck on Turbopack Dev Server
How I debugged and fixed the Next.js 16 Turbopack dev server that kept crashing at 'Compiling /[locale]' after migrating to Tailwind CSS v4.
○ Compiling /[locale] ... with exit code 1. No error message. No stack trace. Just... dead.
This note documents the full debugging journey—every wrong turn and the final fix—so you don't have to waste hours on the same problem.
The Symptom
npm run dev, the Turbopack server would start fine:
▲ Next.js 16.1.6 (Turbopack)
- Local: http://localhost:9003
✓ Starting...
✓ Ready in 1552ms
○ Compiling /[locale] ...
# ← process dies here, exit code 1The Wrong Turns
Attempt 1: Restarting the Server
The most obvious first step. Kill the process, restart. Same result every time—stuck at the same point.Attempt 2: Checking Port Conflicts
I suspected port9003 was already in use:
netstat -ano | findstr :9003Attempt 3: Reverting Git Commits
I even rolled back to an older commit (c640944 — the pre-migration backup) to rule out code changes. The older Tailwind v3 codebase had its own issues with the newer dependencies, so this wasn't a viable path either.
Finding the Root Cause
.next cache completely.Remove-Item -Recurse -Force .next/[locale] route in SnipGeek is heavy—it imports Firebase, Radix UI, Framer Motion, Recharts, and many other dependencies. The default Node.js heap size (~1.7 GB) was not enough for Turbopack to compile everything.$env:NODE_OPTIONS="--max-old-space-size=4096"
npx next dev --turbopack -p 9003middleware to proxy. The file was already renamed to src/proxy.ts, but the exported function was still called middleware:// ❌ Before (crashes silently)
export function middleware(request: NextRequest) { ... }
// ✅ After
export function proxy(request: NextRequest) { ... }✓ Ready in 2.3s
○ Compiling /[locale] ...
GET / 200 in 9.2s (compile: 7.8s, proxy.ts: 82ms, render: 1249ms)The Permanent Fix
dev script in package.json to always allocate sufficient memory:
{
"scripts": {
"dev": "cross-env NODE_OPTIONS=--max-old-space-size=4096 next dev --turbopack -p 9003"
}
}Why This Happened
| Factor | Detail |
|---|---|
| Turbopack + large route | The /[locale] layout imports 15+ heavy packages (Firebase, Radix UI, Framer Motion, etc.) |
| Default memory limit | Node.js defaults to ~1.7 GB heap, insufficient for bundling all dependencies |
| Silent OOM | Turbopack doesn't surface out-of-memory errors clearly—the process just exits with code 1 |
NODE_OPTIONS=--max-old-space-size=4096. This alone solves many Turbopack compilation crashes.Key Takeaways
- Silent exit code 1 during Turbopack compilation is often an OOM issue. Always check memory allocation first.
- Clear
.nextcache after major migrations. Stale cache can cause unpredictable compilation failures. - Next.js 16 requires
proxyexport, notmiddleware. The error message for this is clear, but it can get buried if other issues crash the server first. - Don't panic-revert. Diagnose systematically before rolling back commits.
Topics in this note
Explore related ideas through the topics connected to this note.
Share this article
Discussion
Preparing the comments area...