Next.js: The edge runtime does not support Node.js 'crypto' module / A Node.js module is loaded ('fs') which is not supported in the Edge Runtime
Middleware or an Edge route imported a Node.js built-in (fs, crypto, path, net) that isn't available on the Edge.
The edge runtime does not support Node.js 'crypto' moduleA Node.js module is loaded ('fs') which is not supported in the Edge RuntimeModule not found: Can't resolve 'fs' Edge Runtime middlewareThe edge runtime does not support Node.js 'path' moduleNode.js API is used (process.nextTick) which is not supported in the Edge Runtime Meaning
Use Web APIs instead (crypto.subtle, fetch, URL) or move that code to a Node.js runtime route. A dependency of your middleware may import a Node module transitively: check the import trace and replace the package.
Common causes
import crypto from "crypto"in middleware- Library depending on
fs/path - Database drivers (pg, mongoose) in Edge code
- Auth libs using Node crypto
- Shared utils imported by middleware
⚡ Quick fix
- Use Web Crypto (
crypto.subtle) in middleware - Keep DB access in Node runtime handlers
- Split shared utils so middleware imports only Edge-safe files
Detailed fix by platform
Next.js
export const runtime = "nodejs"; // for routes that need Node APIs
How to diagnose
- Import — Which module?
- Trace — Who imports it?
- Runtime — Edge?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Conflicting app and page file was found Next.js: ⨯ Conflicting app and page file was found, please remove the conflicting files to continue: "pages/index.tsx" - "app/page.tsx"
- Dynamic Code Evaluation not allowed in Edge Runtime Next.js: Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
- Edge Function size limit exceeded Vercel: The Edge Function "middleware" size is 1.2 MB and your plan size limit is 1 MB. Learn More: https://vercel.link/edge-function-size
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026