Skip to content
Latchkey

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.

vite
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

  1. Compare the import path to the actual file name and folders, exactly.
  2. Rename the import or the file so the case matches.
  3. Re-run the build on a case-sensitive filesystem to confirm.
Terminal
git mv src/components/button.tsx src/components/Button.tsx

Configure 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
// 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →