Module not found
Module not found: Can't resolve '…'
Your code imports a package or file that cannot be found at the name the import uses.
What it means
While building, Next.js followed an import in your code and found nothing at that name. The name in quotes is what it looked for, and the error names the file that asked for it. The build stops, so there is nothing to deploy until it is fixed.
Common causes
- The package is not installed. It is imported, but it is not in
package.json, ornode_modulesis out of date. Install it with your package manager. - The path is wrong. The file lives in a different folder from the one the import points to: one
../too many or too few. - The capital letters do not match.
import Button from './button'will not findButton.tsxon a system that treats case as different, which includes the Linux machines most builds run on, even when it works on your computer. - A Node.js-only module is used in browser code. Modules such as
fsexist on the server, not in the browser.
A prompt to fix it
Paste it into your AI coding tool and fill in the parts in angle brackets. It asks the tool to find the cause and show you before it changes anything.
Paste it, then fill in the <angle brackets>
My build fails with: Module not found: Can't resolve '<the name in quotes>' in '<the file it names>'.
Before changing anything, find out which of these it is and show me the evidence:
1. Is it a package? Check whether it is listed in package.json and present in node_modules.
2. Is it a file? Check that the import path points to a file that exists, folder by folder, and that every capital letter matches the real file name exactly.
3. Is it a Node.js module such as fs or path, imported by code that runs in the browser?
Fix only the cause you found. Do not rename other files or add packages I did not ask for. Then run the build and show me that this error is gone.How to check it is fixed
- The build output no longer mentions this module.
- If the fix was a change of capital letters in a file name, check that
git statusshows the rename before you push. A rename that only changes case is easy to miss.
Tested prompts that help
- Hand It An Error — If the fix above does not do it, or your error is close to this one but not quite, this prompt hands your AI tool the whole error, what you expected, the last thing you changed and what you already ruled out, and makes it name the cause before it changes anything. Test log: Pass, ChatGPT (Pro), September 27, 2026; Pass, Claude.ai (Fable 5.1 Max), September 27, 2026.
- Verify The Imports — If the missing package is one the AI added, check that it exists at all before you install anything. This prompt makes it prove every import is real and works in the version you have. Test log: Partial, ChatGPT (Pro), September 27, 2026.
Sources
Everything above comes from these pages. We read them on September 27, 2026; if one has changed since, it wins.