Import component fail and can't use them
Hi ! I have some problem for a couple hours now and Google is no help 😮
I learn Nuxt 4 and I try this from the nuxt website : https://nuxt.com/docs/4.x/getting-started/views#components
But when I try, Nuxt (or Vue) don't want to find my AppAlert component. And leave me with these kind of errors
And in browser console I have following screen. I tried some solutions from Google but without any resolve.
If someone have an idea it would be really cool !

4 Replies
Hi @Ggcool. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It sounds like you're following the Nuxt 4 documentation example for auto-imported components, but Nuxt/Vue can't find your
Make sure your
Ensure your
Sometimes, Nuxt needs a restart to pick up new files in the
Double-check the spelling and casing of both the filename and the tag in your template. Nuxt uses PascalCase for auto-imported components. 5. No Manual Import Needed
You do not need to manually import components from the
Your
AppAlert
component and is showing warnings like "Failed to resolve component: AppAlert".
Here are some things to check, based on the official Nuxt documentation:
1. Component Location and NamingMake sure your
AppAlert.vue
file is inside the components/
directory at the root of your project. For example:
Nuxt will automatically import any components in this directory, and you should be able to use <AppAlert />
in your templates without importing it manually. The filename should match the component name you use in your template (case-sensitive) Nuxt components directory.
2. Component TemplateEnsure your
AppAlert.vue
file has a valid template. For example:
If your component is missing a template or render function, you'll see the "Component <Anonymous> is missing template or render function" warning Nuxt views: components.
3. Restart the Dev ServerSometimes, Nuxt needs a restart to pick up new files in the
components/
directory. Stop and restart your development server.
4. Check for TyposDouble-check the spelling and casing of both the filename and the tag in your template. Nuxt uses PascalCase for auto-imported components. 5. No Manual Import Needed
You do not need to manually import components from the
components/
directory in your script. Nuxt auto-imports them for you.
6. Example UsageYour
app.vue
should look like this:
And your components/AppAlert.vue
:
If you've checked all of the above and it still doesn't work, there may be a misconfiguration in your project. In that case, try creating a minimal reproduction or check your nuxt.config.ts
for any custom components
configuration that might interfere with auto-imports Nuxt auto-imports.
If you continue to have issues, consider sharing your project structure and relevant code snippets for more targeted help.
Let me know if this helps or if you need further assistance!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@210746828851773440> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
As the bot asking this is my project structure in pic below, created by
npm create nuxt@latest
and I tried everything listed in the bot response... I'm out of ideas
It's okay, flapili told me in #french that the component folder must be in app and not in root ! It's good