What it means
Your code imports a file or a package, and the build cannot find it. Webpack, Next.js and Create React App say "Module not found". Vite says "Could not resolve", or "Rollup failed to resolve import". They all mean the same thing.
How to fix it
-
Check the capital letters
If the import is
./components/Buttonand the file isbutton.tsx, it works on Windows and macOS and fails on Linux, because Linux treatsButtonandbuttonas different files. Make the import and the file name match exactly. -
Check that the file was sent
A file that is not committed, or is ignored by
.gitignore, is not part of what was sent. Commit it. -
If it is a package, add it
If the import is a package name, add it to
dependenciesinpackage.json, and commit the lock file.
Renaming a file that only changes capital letters
Git on Windows and macOS can miss a rename that only changes capital letters. Use git mv:
git mv src/components/button.tsx src/components/Button.tsx