Nuxt: [vite] Internal server error: Failed to resolve import "~/components/Foo.vue" from "pages/index.vue". Does the file exist?
Vite couldn't resolve an alias import — the file doesn't exist at that path or the alias isn't defined.
[vite] Internal server error: Failed to resolve import "~/components/Foo.vue" from "pages/index.vue". Does the file exist?Failed to resolve import "@/components/Button.vue"Failed to resolve import from. Does the file exist? Nuxt[plugin:vite:import-analysis] Failed to resolve import "~/composables/useX" 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)
.nuxtstale after config change- Alias not defined in plain Vite
- Components auto-imported but imported manually with wrong path
⚡ Quick fix
- Verify the real path/case; use
~/components/Foo.vuerelative to srcDir npx nuxi prepare/ delete.nuxtand restart- Define alias in
vite.config+ tsconfigpaths
Detailed fix by platform
Nuxt
npx nuxi cleanup && npx nuxi prepare && npm run dev
How to diagnose
- Path — Exists/case?
- Alias — Root?
- Cache — .nuxt?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- [Vue warn]: Error in v-on handler / Error in mounted hook (Vue 2) Vue 2: [Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'x' of undefined"
- [vuex] unknown mutation type / unknown action type Vuex: [vuex] unknown mutation type: SET_USER / [vuex] unknown action type: fetchUser
- Could not Fast Refresh [vite] hmr invalidate … Could not Fast Refresh. Export is incompatible.
Most viewed in Vue
- Property was accessed during render but is not defined Vue: [Vue warn]: Property "x" was accessed during render but is not defined on instance
- Failed to resolve component Vue: [Vue warn]: Failed to resolve component: x
- Avoid mutating a prop directly Vue: [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026