# Nuxt: [vite] Internal server error: Failed to resolve import "~/components/Foo.vue" from "pages/index.vue". Does the file exist?

**Code:** `Nuxt/Vite: Failed to resolve import "~/..." or "@/..."` · **Category:** Vue · **Seen on:** Vue, Node.js

Vite couldn't resolve an alias import — the file doesn't exist at that path or the alias isn't defined.

## Meaning

In Nuxt `~`/`@` point to `srcDir` (app root, `app/` in Nuxt 4) and `~~`/`@@` to the project root. Check file name case, extension and location; run `nuxi prepare` to regenerate `.nuxt/tsconfig.json`. In plain Vite define `resolve.alias` and mirror it in tsconfig `paths`.

## Common causes

- File missing/misnamed/case mismatch
- Wrong alias root (srcDir changed in Nuxt 4)
- `.nuxt` stale after config change
- Alias not defined in plain Vite
- Components auto-imported but imported manually with wrong path

## Quick fix

1. Verify the real path/case; use `~/components/Foo.vue` relative to srcDir
2. `npx nuxi prepare` / delete `.nuxt` and restart
3. Define alias in `vite.config` + tsconfig `paths`

## Detailed fix by platform

### Nuxt

1. `npx nuxi cleanup && npx nuxi prepare && npm run dev`

## How to diagnose

1. **Path** — Exists/case?
2. **Alias** — Root?
3. **Cache** — .nuxt?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/vue/nuxt-alias-failed-to-resolve-import)
