"ref is not defined" in custom module only when installed as an external dependency
I get this error only when installing my module from another project of mine. In the playground everything works fine.
What could be the problem here?
12 Replies
Hi @nborges. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the knowledge sources provided do not contain explicit information about the "ref is not defined" error in a custom Nuxt module when installed as an external dependency. There is no direct documentation or discussion in the sources about this specific scenario or its root causes.
If you have more details or a code sample, I can help look for related patterns or issues in the provided sources. Otherwise, based on the current knowledge sources, I cannot provide a confident answer to your question.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@968208466286092359> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
No luck with good old kapa.ai. Any ideas?
@nborges do you fix that? I have the same issue, it works in playground but in other projects it gives me save error.
@DGINX Did you able to solve your issue?
Unfortunately no
Are you auto-importing in your module?
When using ref inside a module it is recommended to explicitly import
@freb97 No, because when i working with PhpStorm, he didn't see this as an issue and don't ask me to auto import. But yes when i add
import { ref } from 'vue' by myself it works as external dependency in other projects.
But, there are still 2 questions open for me.
1) How i can enable this is in PhpStorm, to auto import this from vue?
2) Why it works in Playground fine without import { ref } from 'vue' but as external dependency not?1) i don't know. i'm using vscode, sorry
2) because when you use ref implicitly without importing, it will translate to
import { ref } from '#imports', which will not be found after building your module when you use it as a package dependency, as a package with name "#imports" does not exist and does not have "ref" as an export.Jetbrains has a big problem with the vue/nuxt syntax
i switched back to vscode from webstorm
a lot of things are also buggy, i had times where a normal
div is supposed to be on the wrong place lmaoI was using jetbrains products exclusively until a few years ago all these vue / nuxt problems annoyed me too much aswell π What sometimes helped was to just restart the language server, in the bottom right of the PhpStorm window you can click the vue icon and restart it.
But honestly since switching to vscode im not missing anything haha
Yeah restarting the language server was the fix for like 20 minutes π