Short answer
A file in the client bundle imports a Node.js module. Follow the import trace. In app/, move Node.js work to a Server Component, a Server Action or a Route Handler on the Node.js runtime. In pages/, use getStaticProps, getServerSideProps or an API route. Pass the result to the component. Add import "server-only" to server files so the next mistake fails clearly.
Rather not fix it yourself? App Fix Ticket fixes one reproducible bug at a fixed price, with an optional Diagnosis that is credited toward the fix.
How server code ends up in the browser
01
A Client Component imports server code
“Once a file is marked with "use client", all of its imports and the components it directly renders are included in the client bundle.” Next.js, Server and Client Components
Everything a "use client" file imports goes to the browser. If it imports your database client or a file that reads from disk, the build tries to bundle fs. Move that call to the server side and pass the result down as props.
02
A shared helper file mixes both
“This means it's possible to accidentally import server-only code into the client.” Next.js, Server and Client Components
A utils file with both a formatting helper and a database call gets pulled into the client by the formatting helper. Split it into a client-safe file and a server file.
03
Mark server files with server-only
“To prevent accidental usage in Client Components, you can use the server-only package.” Next.js, Server and Client Components
Import it at the top of each server file, as below. If a Client Component then imports that file, the build fails with a clear error pointing at the mistake. In Next.js, installing the server-only package is optional; install it (npm install server-only) if your lint rules flag undeclared dependencies.
import 'server-only'04
In the Pages Router, outside getServerSideProps
“The module you're trying to import uses Node.js specific modules, for example dns, outside of getStaticProps / getStaticPaths / getServerSideProps” Next.js, Module Not Found
In pages/, keep file reads in getStaticProps, getStaticPaths, getServerSideProps or a Node.js API route under pages/api/. The page component itself must also run in the browser.
Checked against the vendor’s docs on : Next.js docs: Server and Client Components; Next.js docs: Module not found.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug. The Fix costs $1,200. If you need a Diagnosis first, its $450 fee counts toward the Fix.See scope and start
- from $450AI-Built App RescueFor a whole-app review, the $450 Launch Check is credited toward the optional $1,950 Rescue Sprint for up to five critical or high findings.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Vercel Module not found: Can’t resolve (casing) · Next.js window is not defined · Vercel npm run build exited with 1 · Next.js Edge Runtime does not support Node.js module