Vite "Failed to resolve import" during build in CI
Vite could not map an import specifier to a real file on disk. The path is wrong, the file is missing, an alias is unconfigured, or the case differs from the actual filename on the case-sensitive CI filesystem.
What this error means
The build fails with "Failed to resolve import './Button' from 'src/App.tsx'. Does the file exist?" even though it builds on a developer machine.
error during build:
Could not resolve "./components/Button" from "src/App.tsx"
Failed to resolve import "./components/Button" from "src/App.tsx". Does the file exist?Common causes
Case mismatch on a case-sensitive filesystem
macOS and Windows are case-insensitive, but Linux runners are not, so ./Button will not match a file named button.tsx.
A missing alias or extension
An import relies on a resolve.alias not configured for the build, or omits an extension Vite does not infer.
How to fix it
Match the import to the real filename case
- Compare the import path to the actual file name and folders, exactly.
- Rename the import or the file so the case matches.
- Re-run the build on a case-sensitive filesystem to confirm.
git mv src/components/button.tsx src/components/Button.tsxConfigure the alias used by the import
If the import uses an alias like @/, define it in resolve.alias so the build resolves it.
// vite.config.js
import { resolve } from 'node:path';
export default {
resolve: { alias: { '@': resolve(__dirname, 'src') } },
};How to prevent it
- Keep import paths matching file name case exactly.
- Define every alias the build relies on in
resolve.alias. - Test the build on Linux locally to catch case issues early.