Nuxt V4 typescript auto import composables from app/composables
Hello everyone, since switching to Nuxt 4 with the new folder structure (frontend in app), typescript is showing errors on composables that should normally be auto-imported. The code runs fine, but red lines are displayed.
Does anyone know how to fix this?
Thanks in advance!

6 Replies
Hi @Smaug. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This issue is common when switching to Nuxt 4’s new directory structure (
Run one of the following commands in your project root: This will generate the
Make sure your composables are in the correct directory:
By default, Nuxt only scans the top level of the
Sometimes, after generating the types, you may need to restart VS Code or reload the TypeScript server for the changes to take effect. Summary:
The red lines are due to missing type declarations for auto-imported composables. Running the Nuxt dev server or
app/composables
) because TypeScript type declarations for auto-imported composables are generated by Nuxt only when the dev server is running or after running certain Nuxt commands. If you create or move composables without the dev server running, VS Code (and TypeScript) won’t recognize them, resulting in red squiggly lines, even though the app works at runtime.
How to fix:
1. Start the Nuxt Dev Server or Run Prepare/BuildRun one of the following commands in your project root: This will generate the
.nuxt/imports.d.ts
file, which provides the necessary type declarations for auto-imported composables. Once this file is generated, VS Code should recognize your composables and the errors should disappear.
2. Check Your Directory StructureMake sure your composables are in the correct directory:
app/composables/
. With the new structure, the ~
alias points to app/
, so ~/composables
resolves to app/composables/
New Directory Structure.
3. Nested ComposablesBy default, Nuxt only scans the top level of the
composables/
directory. If you have composables in nested folders, you need to either re-export them in composables/index.ts
or configure the scanner in your nuxt.config.ts
:
See details and examples.
4. Restart VS CodeSometimes, after generating the types, you may need to restart VS Code or reload the TypeScript server for the changes to take effect. Summary:
The red lines are due to missing type declarations for auto-imported composables. Running the Nuxt dev server or
nuxi prepare
will generate the necessary types and resolve the issue in VS Code composables directory usage.
If you still have issues after following these steps, ensure your Nuxt version is up to date and that your nuxt.config.ts
is correctly set up for the new structure.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@611468402263064577> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
My new tsconfig.json:
But if I run
bunx nuxi prepare
and bunx nuxi typecheck
I have errors on auto-imported components and composables
Update: Solved by moving dependencies from devDependencies to dependenciesHey, what dependencies did you move around, i'm having the same problem right now
Moving everything from devdeps to deps didnt change anything for me, so if anyone has an answer at some point, i'd really love some insights
(it shouldn't have changed anything anyway :'))
Did you try to remove node_modules and .nuxt and reinstall all ? it worked for me
Yeah, sadly it didnt fix it for me, i'll try other things i guess.... :/