Skip to content
Latchkey

Vite "Could not load ... ENOENT no such file or directory" during build in CI

Vite resolved an import to a path but the file is not there. ENOENT means the operating system reported no such file, usually because of a wrong path, a case mismatch on Linux, or an asset that CI never generated.

What this error means

The build fails with "Could not load /app/src/assets/logo.png (imported by src/App.tsx): ENOENT: no such file or directory" during vite build.

vite
error during build:
Could not load /app/src/assets/logo.png (imported by src/App.tsx):
ENOENT: no such file or directory, open '/app/src/assets/logo.png'

Common causes

The file is missing or uncommitted

An asset referenced by an import was not committed, or is generated by a step that did not run before the build.

A case mismatch on a case-sensitive runner

The import case differs from the real file name; Linux runners treat Logo.png and logo.png as different files.

How to fix it

Ensure the file exists at the imported path

  1. Confirm the asset is committed and present at the exact path and case.
  2. If it is generated, run the generating step before the build.
  3. Re-run vite build to confirm it loads.
Terminal
git status --porcelain src/assets
ls -l src/assets/logo.png

Fix the import path case

Rename the import or the file so the case matches what exists on disk.

Terminal
git mv src/assets/Logo.png src/assets/logo.png

How to prevent it

  • Commit every asset your imports reference.
  • Run asset-generating steps before the Vite build.
  • Match import path case to real file names for Linux runners.

Frequently asked questions

What causes ""Could not load" (ENOENT)"?
An asset referenced by an import was not committed, or is generated by a step that did not run before the build.
How do I fix "Could not load" (ENOENT)?
Ensure the file exists at the imported path

Related guides

References

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