N
Nuxt2mo ago
Uchuu

Nuxt not auto importing

Its not auto importing its red squiglggly lines over all imports
No description
5 Replies
kapa.ai
kapa.ai2mo ago
Hi @Uchuu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- If Nuxt is not auto-importing and you see red squiggly lines over all imports, here are some possible causes and solutions based on the knowledge sources: 1. Auto-imports Disabled in nuxt.config
Check your nuxt.config.ts for the imports option. If you have:
exports default defineNuxtConfig({
imports: {
autoImport: false
}
})

exports default defineNuxtConfig({
imports: {
autoImport: false
}
})

then auto-imports are completely disabled. In this case, you must use explicit imports from #imports:
import { ref, computed } from '#imports'

import { ref, computed } from '#imports'

Disabling Auto-imports (Nuxt 3)
Disabling Auto-imports (Nuxt 4) 2. Partial Auto-imports Disabled
If you have:
exports default defineNuxtConfig({
imports: {
scan: false
}
})

exports default defineNuxtConfig({
imports: {
scan: false
}
})

then only framework functions like ref and computed are auto-imported, but your custom composables and utils are not. You need to import your own code manually in this case.
Partial Disabling 3. TypeScript/IDE Issues
If you have followed the documentation and auto-imports should be working, but your IDE still shows errors, make sure: - You have restarted your IDE after changing config. - Your node_modules and .nuxt directories are up to date (try deleting and reinstalling them). - You have followed the TypeScript setup instructions for Nuxt. 4. Explicit Imports When Auto-imports Are Disabled
If auto-imports are disabled, you must use the #imports alias for Nuxt/Vue composables:
import { defineAppConfig } from '#imports'

import { defineAppConfig } from '#imports'

GitHub Issue Example If none of these solutions resolve your issue, please check your Nuxt version and configuration, and ensure you are not using a custom directory structure that is not covered by Nuxt's auto-import system. If you need more specific help, please provide your nuxt.config.ts and a sample of your directory structure. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@1035470271441805353> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Uchuu
UchuuOP2mo ago
I tried deleting and regenerate the nuxt and node_modules folder but it doesnt owrk I tried deleting and regenerate the nuxt and node_modules folder but it doesnt owrk @kapa.ai
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- If deleting and regenerating the .nuxt and node_modules folders did not resolve the issue with auto-imports not working and red squiggly lines appearing, the knowledge sources suggest checking your nuxt.config.ts for the imports configuration. If you have set autoImport: false, auto-imports will be completely disabled and you must use explicit imports from #imports instead. For example:
import { ref, computed } from '#imports'
import { ref, computed } from '#imports'
If you want auto-imports to work as usual, ensure that your nuxt.config.ts does not have autoImport: false under the imports option, or set it to true or remove the option entirely. Also, if you have imports.scan: false, only framework functions like ref and computed will be auto-imported, and your custom composables will require manual imports Nuxt 4 Auto-imports. If you have already checked these settings and the problem persists, the knowledge sources do not provide further troubleshooting steps beyond what you have already tried. If possible, double-check your configuration and directory structure, and ensure you are not overwriting important TypeScript paths or aliases in your tsconfig.json Nuxt 4 TypeScript. If the issue continues, you may need to seek further help by providing your configuration and setup details, as the knowledge sources do not contain more specific solutions for this scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@1035470271441805353> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?