Vite "Could not load ... ENOENT: no such file or directory"
Vite resolved an import to a path, then the OS could not open it (ENOENT). The file is genuinely missing on the runner - most often a casing mismatch on case-sensitive Linux, an uncommitted file, or a wrong extension.
What this error means
vite build fails with Could not load /app/src/...: ENOENT: no such file or directory, naming the missing path and the file that imported it. It frequently passes on macOS and fails only in CI.
error during build:
Could not load /app/src/components/Header.tsx (imported by src/App.tsx):
ENOENT: no such file or directory, open '/app/src/components/Header.tsx'Common causes
Case mismatch on the runner
The import says ./components/Header but the file is header.tsx. macOS resolves it; case-sensitive Linux CI returns ENOENT.
File not committed or wrong extension
The referenced file is gitignored/uncommitted, or the import omits/uses the wrong extension so the path on disk does not exist.
How to fix it
Match the import to the real filename
- Compare the import string to the actual filename, character and case for character.
- Rename the file or the import so they match exactly.
- Confirm the file is tracked in git (
git ls-files | grep Header).
Reproduce case sensitivity locally
Catch the bug before CI by checking out on a case-sensitive volume or adding a lint check.
git ls-files src/components/
# verify the committed name matches the import exactlyHow to prevent it
- Match import casing to filenames; Linux runners are case-sensitive.
- Ensure every imported file is committed, not gitignored.
- Use a case-sensitivity lint or a case-sensitive dev volume to catch it early.