Module not found: Can't resolve './Component' — works locally, fails on Vercel
Quick answer
Your local filesystem (macOS/Windows) is case-insensitive, but Vercel builds on Linux, which is case-sensitive. An import like `./Button` will resolve locally even if the file is actually named `button.tsx`, but fails on deploy. Fix the casing to match exactly.
What causes this error
macOS and Windows filesystems are case-insensitive by default — import Button from './button' will happily resolve to a file named Button.tsx. Vercel's Linux build environment is case-sensitive, so the exact same import fails there with a module-not-found error, even though it builds fine on your machine.
The Fix
- Find the mismatched import — check the exact filename on disk versus what's written in the import statement
- Correct the import path's casing to match the file exactly
- As a habit going forward: name files and their imports consistently (e.g. always PascalCase for components) to avoid this recurring
Common causes / variations
- Renaming a component file without updating every import that references it
- Copy-pasting an import from a different file with a slightly different casing convention
- Auto-import suggestions in your editor picking a differently-cased path than the actual file
Related errors
See also: ENOENT routes-manifest.json, environment variable not found on Vercel.
Was this fix helpful?
Comments
Loading comments...