Using nuxtjs/i18n types in a module
My last few braincells are fighting eachother over this problem..
Working on a nuxt module that uses nuxtjs/i18n.
I am using
Typescript does not throw any errors during development.
Trying to build the module, it suddenly throws
I have no idea whats going on.. Taking a look at the referred types file.
The problem is being pointed to the opening bracket
{
in the import statement.
16 Replies
@Bazze - unfortunately I don't have an answer for you here but I can tell you I have more trouble with this package (and really what it wraps around - the vue i18n) then I know what to do with. I have strugged with issue and after issue with it. I just keep jiggling the handle until I get it to work. I'm interested to see if anyone actually has an answer for you.
You're in my prayers sir. 🙂
@Bazze check this module :
https://github.com/xibman/nuxt-zod-i18n/blob/main/src/module.ts
GitHub
nuxt-zod-i18n/src/module.ts at main · xibman/nuxt-zod-i18n
Easily Translate Zod's error messages on nuxt. Contribute to xibman/nuxt-zod-i18n development by creating an account on GitHub.
it use type from i18n without any problem
but you need a recent version of nuxt/i18n
According to my .lock the nuxtjs/i18n is resolved to 8.3.1, which is the latest version.
At the moment the only import i have from nuxtjs/i18n is
What node version do you use to build nuxt-zod-i18n?
still on 18 branch
Tried building with bun instead a few times, but kept throwing the same error.
Restarted vscode, and then it would build with yarn. Tried editing some things, the same error appeared.
I then tried building with bun again and it would.
A few times back and fourth.
Thank you guys for your input.
If i run into this or actually find the reason why ill post it.
At the moment it seems like either the terminal or vscode is interfering with typescript. But i dont see how it would.
you create a module like the one before
or you are already in a nuxt app ?
I created a standalone module.
do you run the command dev:prepare ?
do you use the template provided by nuxt ?
GitHub
GitHub - nuxt/starter at module
Create a new Nuxt project, module, layer or start from a theme with our collection of starters. - GitHub - nuxt/starter at module
At first i was using prepack, but jiti didnt play along so well with one of my exports, so i tried to prepack the module which is when i ran into the issue.
Yes, it is the module template generated with nuxi
okay
for the zod module i use node / pnpm
no problem with types
Im using yarn for the workspaces in a monorepo with turborepo.
if you have multiple version of nuxt-i18n installed the monorepo the problem can come from here
It all seems to resolve to the latest in the yarn.lock
not sure if this will work but try this:
import { type LocaleObject } from '#i18n'