Vite failed to resolve import ⚛️ React

[vite] Internal server error: Failed to resolve import "x" from "src/App.jsx". Does the file exist?

Vite couldn’t find an imported file or package.

Seen on: React

Meaning

Wrong relative path, case mismatch, path alias not configured in vite.config, or package not installed.

Common causes

  • Wrong relative path or file extension
  • Alias (@/) defined in tsconfig but not in vite.config
  • Package not installed
  • Case mismatch on Linux CI

⚡ Quick fix

  1. Fix the path or install the package
  2. Add resolve.alias in vite.config (or vite-tsconfig-paths)
  3. Match file name case exactly

Detailed fix by platform

React

  1. resolve: { alias: { '@': path.resolve(__dirname, 'src') } }

How to diagnose

  1. Import — Which specifier?
  2. Alias — Configured in Vite?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.