Next.js Module not found (Can't resolve)
Next.js can't resolve an import: the package isn't installed, the path or filename case is wrong, or a Node-only module (like fs) is imported into browser code. Install the dependency, fix the path, or keep server-only imports out of client components.
Cause: Missing dependency, wrong path/case (Linux builds are case-sensitive), or Node-only module in client code.
How to fix it
- Read the module name in the error.
- If it's a package, add it to
dependenciesand commit the lockfile. - Check path and filename case exactly (
./Buttonvs./button). - For
fs/patherrors, move that code to a Server Component, route handler orgetServerSideProps.
Example
Illustrative example, not from a customer project.
- import Button from './button'
+ import Button from './Button'
FAQ
Why does it build on my Mac but fail on Vercel?
macOS is case-insensitive by default; the Linux build server isn't.
Why Can't resolve 'fs'?
fs exists only in Node.js; it can't be bundled for the browser.
Get a $149 diagnosis See pricing Launching soon? The Launch Path gets you ready for $1,195 flat.
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- read-only access; fixes arrive as pull requests you merge
- Your $149 diagnosis is credited in full toward any paid job.