Vite build stops with [vite:load-fallback] Could not load a file
[vite:load-fallback] Could not load /src/components/Header (imported by src/App.tsx)Short answer
The message names two files: the one Vite could not read and the file that imports it. Open the importing file and compare the import with the real file name on disk. The usual causes are a different letter case that only fails on Linux, or an alias that points at a relative path instead of an absolute one.
Fix it fast
1Find out which cause you have
Copy the path from the error and list what is really in that folder. Compare name, letter case and extension with the import in the file named after 'imported by'.
ls -la src/components/ git ls-files src/components | head -n 302Match what you see, then jump to its fix
What does the error look like?
[vite:load-fallback] Could not load /src/components/Header (imported by src/App.tsx)ENOENT: no such file or directoryModule not found
Cause 1 of 2
Import and file name differ only by letter case
1Check
Vite's troubleshooting page lists this as the cause of ENOENT and Module not found when a project built on Windows or macOS is built on Linux. Check that git stores the same case as the import.
git ls-files | grep -i "header"
grep -rn "components/header" src2Fix
Make the import match the file name exactly. If the file was renamed only by case, rename it through git so the index changes too.
git mv src/components/header.tsx src/components/Header.tsx
# import { Header } from './components/Header'3Verify
Build again on the Linux machine that failed.
npx vite buildConfirmed by vite.dev
Cause 2 of 2
An alias points at a relative path
1Check
Read resolve.alias in the Vite config. Vite uses a relative alias value as it is written and does not turn it into a file system path.
grep -n -A6 "alias" vite.config.*2Fix
Give the alias an absolute path built from the config file location.
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
})3Verify
Restart the dev server and run a build.
npx vite buildConfirmed by vite.dev
How do I stop it coming back?
- Run the build on Linux in CI so a case mismatch fails before release.
- Use git mv for renames that only change letter case.
- Write alias targets as absolute paths with fileURLToPath.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
npm start runs, but the browser does not refresh when you save a file
Saving a file does nothing while npm start is running
The watcher behind npm start is not seeing your edit.
4 causes, each with a fixWeb apps
django-tailwind cannot find the npm executable (cPanel, Windows, Linux)
CommandError raised by the tailwind management command about npm
django-tailwind runs npm as a subprocess, and Python sometimes cannot find it.
3 causes, each with a fixWeb apps
Node.js fails with uv_cwd ENOENT when its folder is gone
npm, node or next fails at start in a terminal whose folder was removed
uv_cwd is how Node.js asks the operating system for its current working directory.
2 causes, each with a fixWeb apps
Playwright cannot open a headed browser on a Linux server or in Docker
npx playwright test --headed shows no window on a Linux server
A headed browser needs a display, and a Linux server or container has none.
3 causes, each with a fixWeb apps
The shell says pnpm: command not found
npx next dev works, but pnpm dev or pnpm install is not found
The shell cannot find a pnpm executable on PATH.
3 causes, each with a fixWeb apps
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fix