Missing Import Errors in Vue
Vue projects throw Failed to resolve component or X is not defined when components or modules aren't properly imported.
Component Registration
<!-- BAD — component not imported -->
<template>
<UserCard :user="user" />
</template>
<script setup>
// Missing import!
</script>
<!-- GOOD -->
<script setup>
import UserCard from '@/components/UserCard.vue';
</script>Auto-Imports with unplugin-auto-import
Nuxt and some Vue projects use auto-imports:
// vite.config.ts
import AutoImport from 'unplugin-auto-import/vite';
export default defineConfig({
plugins: [
AutoImport({
imports: ['vue', 'vue-router', 'pinia'],
}),
],
});With this, ref, computed, watch etc. don't need manual imports.
Composition API Imports
<script setup>
// These are needed without auto-import
import { ref, computed, onMounted, watch } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { storeToRefs } from 'pinia';
import { useUserStore } from '@/stores/user';
const router = useRouter();
const userStore = useUserStore();
const { currentUser } = storeToRefs(userStore);
</script>Path Aliases
// vite.config.ts
import { resolve } from 'path';
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
});// tsconfig.json
{
"compilerOptions": {
"paths": {
"@/*": ["src/*"]
}
}
}Bugsly captures Vue component resolution errors and module import failures in production, including the component tree context showing where the missing component was referenced.
Try Bugsly Free
Track up to 100 issues per month on the free plan; events are not billed.
Get Started FreeRelated Articles
Fix Missing Import in PHP
Resolve PHP class not found errors, covering namespace use statements, Composer autoloading, and PSR-4 mapping issues.
Read moreHow to Decode JWT Tokens Safely (Without Leaking Secrets)
Learn how JWTs work, how to decode them safely for debugging, and why you should never paste tokens into random online tools.
Read moreHow to Fix DNS Resolution Error in PHP
Learn how to fix the DNS Resolution Error in PHP. Step-by-step guide with code examples.
Read moreHow to Fix DatabaseError in Python
Learn how to fix the DatabaseError in Python. Step-by-step guide with code examples.
Read moreFrom the same team
SEOBolt
Technical SEO and AI search audits with ready-to-apply fix plans.
Try SEOBolt →GrowFast
Domain in, qualified B2B leads out, with cold outreach and deliverability handled.
Try GrowFast →AutoShort
Turn a topic into a faceless short: AI script, voiceover and captions.
Try AutoShort →RemixViral
Paste a long video and get back the moments worth posting, cut vertical and captioned.
Try RemixViral →