Nuxt/Vite: Failed to resolve import "~/..." or "@/..." Vue Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see [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"
Seen on: Vue Node.js

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?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

[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" (Vue)[Vue warn]: Error in …[vuex] unknown mutation type / unknown action type — Vuex: [vuex] unknown mutation type: SET_USER / [vuex] unknown action type: fetchUser (Vue)[vuex] unknown mutati…Could not Fast Refresh — [vite] hmr invalidate … Could not Fast Refresh. Export is incompatible. (React)Could not Fast RefreshError: [vuex] do not mutate vuex store state outside mutation handlers — Vuex (strict mode): Error: [vuex] do not mutate vuex store state outside mutation handlers. (Vue)Error: [vuex] do not …Module not found: Can't resolve 'x' (Next.js build) — Next.js: Module not found: Can't resolve '@/components/Button' / 'lodash' in '/app/src' (Next.js)Module not found: Can…Nuxt 404: Page not found (route/file naming) — Nuxt: 404 Page not found: /blog/my-post / [Vue Router warn]: No match found for location with path (Vue)Nuxt 404: Page not fo…Nuxt: Failed to fetch dynamically imported module (after deploy) — Nuxt: [nuxt] error caught during app initialization TypeError: Failed to fetch dynamically imported module / Loading chunk failed (Vue)Nuxt: Failed to fetch…Nuxt: Hydration completed but contained mismatches — Nuxt: [Vue warn]: Hydration completed but contains mismatches. (Vue)Nuxt: Hydration compl…Nuxt/Vite…

Explore the map of this error Full error map →

🧠 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.