Fix guides · Lovable, Bolt, Cursor, Claude Code, Windsurf ·

Fix Vite "Failed to resolve import … Does the file exist?"

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

"Failed to resolve import" means Vite followed an import line and found nothing at that path, so it can't build the page. The file was renamed or deleted, the spelling or capitalisation differs, the @/ alias isn't set up in vite.config, or the import names an npm package that isn't installed. The error tells you exactly which import and which file to look at.

Free · 3 a day · no signup

Common causes – and how to tell which one you have

1. The file was renamed, moved or deleted

How to tell: The file doesn't exist at the path in the error, but a similar one does (Navbar.tsx moved to layout/Navbar.tsx, or Header.tsx replaced it). Often happens right after an AI edit or refactor.

Fix: Restore the file, or update the import to the new name and path. Search the whole project for the old path, because AI edits often leave several stale imports behind.

2. Upper/lower case doesn't match

How to tell: The import says ./components/navbar but the file is Navbar.tsx. It may work on your Mac or Windows machine and fail on Linux, in Lovable/Bolt previews or on Netlify/Vercel.

Fix: Make the import match the file name exactly. If you renamed only the case, rename via git (git mv) so the change is committed.

3. The @/ alias isn't configured for Vite

How to tell: Every import starting with @/ fails, while relative imports (./, ../) work. tsconfig.json may have paths set, but vite.config has no resolve.alias.

Fix: Add resolve: { alias: { '@': path.resolve(__dirname, './src') } } to vite.config.ts (or use the vite-tsconfig-paths plugin), and keep tsconfig paths pointing to the same folder.

4. The npm package isn't installed

How to tell: The import is a package name like "react-router-dom" or "@supabase/supabase-js", and it's missing from package.json or node_modules.

Fix: Install it (npm install react-router-dom). In Lovable or Bolt, ask the tool to add the package as a dependency instead of editing imports.

5. Stale Vite cache after big changes

How to tell: The file clearly exists with the right name, but the error stays after you fixed it, or appears after switching branches or reinstalling packages.

Fix: Stop the dev server, delete node_modules/.vite, and start it again with npm run dev -- --force.

How to fix it

  1. Read the two paths in the error: the first is what's imported, the second is the file that imports it.
  2. Check whether the imported file exists at that path, letter for letter, including upper/lower case and folder names.
  3. If the import starts with a package name (no ./ or @/), check package.json and run npm install, or install the missing package.
  4. If the import starts with @/, check that vite.config has a resolve.alias for @ pointing to src (tsconfig paths alone are not enough for Vite).
  5. Search the project for the old path and fix every import that still uses it.
  6. Restart the dev server (and delete node_modules/.vite if it keeps showing the old error), then run npm run build to confirm.

Using Lovable, Bolt or v0?

In Lovable or Bolt, paste the full error and say: "Check whether this file exists. If it was renamed or removed, fix every import that still points to the old path. If it's a package, add it to the dependencies. Don't create an empty placeholder file."

Using Cursor, Claude Code or Windsurf?

Ask Cursor or Claude Code to search the codebase for the failing path, list all imports that use it, compare them with the real file names (case-sensitive), and check vite.config.ts for the @ alias. Then have it run npm run build to catch any other broken imports at once.

The “fix” to avoid

Agents sometimes create an empty file at the missing path or comment out the import. The error goes away, but the page loses its component or crashes at runtime. Find out where the real file went and point the import there.

Copy-paste fix prompt for your AI coding tool

Paste this into Cursor, Claude Code, Lovable or Bolt:

Vite fails with "Failed to resolve import ... from ... Does the file exist?". Take the imported path and the importing file from the error. Check: 1) does the file exist with exactly that name and capitalisation? If it was renamed or moved, update this import and every other import of the old path; 2) if it's an npm package, is it in package.json and installed? 3) if it uses @/, does vite.config.ts define resolve.alias for @ pointing to ./src? Don't create empty placeholder files to silence the error. Run npm run build at the end and show me the output.
Your error looks a bit different? Paste your exact error and get a diagnosis tailored to your code — free.

Questions people ask

Why does it work locally but fail on deploy?

Most likely a capitalisation mismatch. macOS and Windows ignore case in file names, Linux build servers don't. Make imports and file names match exactly.

Why does Vite ignore my tsconfig paths?

TypeScript uses paths only for type checking. Vite resolves imports itself, so it needs its own resolve.alias in vite.config (or the vite-tsconfig-paths plugin).

The error names a file inside node_modules. What now?

A package imports something it can't find, often because of a broken install or mixed versions. Delete node_modules, run a clean npm install, then check that the package's version fits your Vite and React versions.

Official documentation

Related errors

Get fixes like this every week