#defineNuxtPlugin is not defined
14 messages · Page 1 of 1 (latest)
It appears that you have to do something like:
import { defineNuxtPlugin, useRuntimeConfig } from '#imports'
in the plugin sort of like this: https://github.com/nuxt/image/blob/main/src/runtime/plugin.ts
Also, it's the same with something like ref - why do I have to import all the things when it's a module?
Auto-imports are not enabled for files within node_modules
So you have to explicitly import them
+you shouldn’t import them from #imports if you do, just use them
Thanks so much @rain aspen - You were totally right on. I found the note in the docs after posting here - not sure how I missed that. Thanks again for clearing that up.
I am now getting a really odd error on the application implementing my code: ERROR: Could not resolve "#imports" It gripes about this in three composables. I've tripled checked and I don't think they are being used outside of a setup function.
Thanks @dim stratus ! any insight on the application not being able to resolve "#imports"?
✅
defineNuxtPlugin(() => {
})
❌
import {defineNuxtPlugin} from '#imports';
defineNuxtPlugin(() => {
})
AutoImports has been disabled
But in a few places where I'm doing something like import { useCookie } from '#imports' I'm getting ERROR: Could not resolve "#imports"
Just want to confirm @dim stratus - if auto-imports are disabled I do have to import them from #imports, correct?
I'm not sure about that, I never disabled auto-imports before. all I know is whenever I accidentally import anything from '#imports' it caused issues which I think isn't where you're supposed to import from. I think you need to import things from where they are located.
Gotcha - yeah, it seems that the module starter kit automatically disables autoimport b/c it's inefficent to have it on for things that are in the node_modules directory (cause thats where it ends up) and that makes sense to me. This error... man... no sense