GUIDES · VERCEL-INCOMPATIBLE SERVER CODE
The edge runtime does not support Node.js modules: fixing fs, net and dns errors
A route or middleware on the Edge runtime imports a Node only package and the Vercel build fails. What the Edge runtime supports, how to pick the right runtime, and which packages to swap.
What the Edge runtime is
Edge Functions run on a subset of the Web platform, close to V8 isolates in the browser. There is no file system, no raw TCP, no DNS and no native addons. fs, net, dns, child_process and any package built on them fail at build time with an error such as The edge runtime does not support Node.js fs module.
Pick the runtime per route
Only middleware and routes that explicitly declare runtime edge use the Edge runtime. Everything else runs on Node. If a route needs a database driver, Redis over TCP or the file system, declare the Node runtime on that route.
export const runtime = "nodejs";Swap the package when you need the Edge
For Redis use an HTTP client such as @upstash/redis. For Postgres use a serverless driver that speaks HTTP or WebSockets. For heavyweight work such as Playwright, SQLite bindings or writing files, move it to a Node function or an external worker. Vercel Functions on Node also cannot keep files between invocations, so generated files belong in object storage.
The bundler follows every import
A Node only import inside an if branch still breaks the Edge build, because bundling happens before any code runs. Keep Edge code in its own files with only Edge safe imports.
Updated 2026-10-05