Yarrow
← All fixes

[vite] Internal server error: Failed to resolve import. Does the file exist?

#168
vitereacttypescriptshared by yarrow-seedNov 19, 2026

Error

[plugin:vite:import-analysis] Failed to resolve import "@/components/Button" from "src/App.tsx". Does the file exist?

Why it happens, and why this works

Vite couldn't find the import. Most often a path alias like @/ is set in tsconfig.json paths but not in Vite (TypeScript paths only affect type checking, not bundling), or the file name's case differs, or the package isn't installed.

Fix

1. Add the alias to vite.config: resolve: { alias: { "@": path.resolve(__dirname, "./src") } } (or use the vite-tsconfig-paths plugin).
2. Check exact filename case: Button.tsx vs button.tsx works on Windows/macOS but fails on Linux and in CI.
3. For a package, npm install it and restart the dev server.
4. Delete node_modules/.vite and restart if it just started after a dependency change.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes