Skip to content
Latchkey

Vite "Could not load <file> (imported by <file>)" - Fix in CI

During vite build, Rollup resolved an import to a path but then failed to read the file from disk. The specifier mapped to something that does not exist - a missing file, a casing mismatch, or an extension the resolver did not append.

What this error means

The build fails with Could not load <path> (imported by <file>): ENOENT: no such file or directory. It surfaces in the production Rollup pass, so vite dev may have tolerated it.

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

Common causes

File missing or wrong case

The imported file does not exist at that path, or its casing differs from the import. Case-sensitive Linux runners fail where macOS did not.

Missing extension the build does not infer

Importing without an extension where the resolver cannot guess it (or an asset import without a matching plugin) leaves Rollup with a path it cannot read.

How to fix it

Verify the file and its exact case

Confirm the target exists at the imported path with matching casing.

Terminal
ls -la src/utils/   # check for format.ts vs Format.ts
# correct the import or rename the file to match

Make extensions resolvable

Add the extension to the import, or configure resolve.extensions so the build can append it.

vite.config.ts
// vite.config.ts
export default defineConfig({
  resolve: { extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'] },
})

How to prevent it

  • Run vite build in CI so disk-load failures surface before deploy.
  • Match import casing to filenames for case-sensitive runners.
  • Keep resolve.extensions aligned with the extensions you omit in imports.

Related guides

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