Skip to content
Latchkey

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.

vite
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

  1. Compare the import string to the actual filename, character and case for character.
  2. Rename the file or the import so they match exactly.
  3. 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.

Terminal
git ls-files src/components/
# verify the committed name matches the import exactly

How 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.

Frequently asked questions

What causes ""Could not load" (ENOENT)"?
The import says ./components/Header but the file is header.tsx. macOS resolves it; case-sensitive Linux CI returns ENOENT.
How do I fix "Could not load" (ENOENT)?
Match the import to the real filename

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card