The edge runtime does not support Node.js module Next.js Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: Next.js Node.js

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

  1. Use Web Crypto (crypto.subtle) in middleware
  2. Keep DB access in Node runtime handlers
  3. Split shared utils so middleware imports only Edge-safe files

Detailed fix by platform

Next.js

  1. export const runtime = "nodejs"; // for routes that need Node APIs

How to diagnose

  1. Import — Which module?
  2. Trace — Who imports it?
  3. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

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" (Next.js)Conflicting app and p…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 (Next.js)Dynamic Code Evaluati…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 (Next.js)Edge Function size li…ERR_TOO_MANY_REDIRECTS (Next.js middleware) — Browser: This page isn't working — redirected you too many times (ERR_TOO_MANY_REDIRECTS) with Next.js middleware / trailing slash (Next.js)ERR_TOO_MANY_REDIRECT…Middleware matcher: Capturing groups are not allowed — Next.js: Error: Invalid middleware found. Capturing groups are not allowed in matcher / `matcher` values must start with `/` (Next.js)Middleware matcher: C…next build: fetch failed ECONNREFUSED (build-time API) — Next.js: Error occurred prerendering page "/blog" TypeError: fetch failed { cause: Error: connect ECONNREFUSED 127.0.0.1:3000 } (Next.js)next build: fetch fai…next build: JavaScript heap out of memory — Next.js: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory (during next build) (Next.js)next build: JavaScrip…The edge …

Explore the map of this error Full error map →

🧠 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.