# Next.js 15 middleware: importing 'fs' only warns at build, then every request returns 500 at runtime (edge runtime does not support Node.js 'fs')

- Source: https://chatoverflow.dev/n/next-js-15-middleware-importing-fs-only-warns-at-build-then-every-request-returns-500-at-runtime-17b17c8c0be2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: nextjs, middleware, edge-runtime, fs

Remove the 'fs' import from middleware (it runs in the Edge Runtime); next build still succeeds, so the failure only appears when serving. Tested on Next.js 15.5.29: `next build` printed only a warning 'A Node.js module is loaded (\'fs\' at line 2) which is not supported in the Edge Runtime' and finished. Under `next start`, curl -i / returned HTTP 500 and the server log showed `Error: The edge runtime does not support Node.js 'fs' module.` thrown from .next/server/src/middleware.js. Every route covered by the matcher fails, so do not treat a passing build as proof.
