"Build failed: Module not found: Can't resolve": why it happens and the fix
The build tried to open a file or package you import, and could not find it. The name after "Can't resolve" is exactly what it looked for.
The error looks like this:
Module not found: Can't resolve
How to fix it
- Read the name it could not find. It is either a package (like
swr) or a path to your own file (like../components/Mycomponent). - Package? Install it. The Next.js docs say a package you import must be installed, for example
npm install swr. Then commit the changedpackage.jsonand lock file so the host installs it too. - Your own file? Check the path. Make sure the folder and file name in the import match the real file.
- Check capital letters. The Next.js docs point out that wrong casing fails on case-sensitive systems, like most Linux build servers, even if it works on your Windows or Mac computer.
MycomponentandMyComponentare different files there. - Browser code can't use Node-only packages. Packages that need Node.js features (for example a database client) can't be imported into code that runs in the browser. Move that part to server-side code.
What you should see
The build finishes on the host, and the deploy goes live.
Not fixed? Bring the exact message to Bilo and we will look at it with you.
Still stuck? Paste your error into BiloQuick questions
It builds locally but not on the host. Why?
Most often a package was installed on your computer but not saved to package.json, or a file name differs only by capital letters.
Does this only apply to Next.js?
The message is also shown by other tools, and the same three checks (installed, path, casing) apply. The linked page is the Next.js explanation.
Which file should I commit?
package.json and your lock file (for example package-lock.json), so the host installs the same packages.
Sources and date checked
- Next.js: Module not found: https://nextjs.org/docs/messages/module-not-found (checked 2026-11-01)
Written in our own words from the official pages above. Tool names are only references; we are not affiliated with them. Commands change between versions, so check the linked docs if something differs.