NuxtConfig typescript error

Hello guys! I have a typescript error that maybe you can help me with:
No description
No description
No description
No description
94 Replies
Fabian B.
Fabian B.2y ago
Hi, can you do npm install again and then start your devserver? Seems like nuxt generated types doesn’t know about that new module yet What’s the typescript error if you hover?
> Rodrigo
> Rodrigo2y ago
No description
> Rodrigo
> Rodrigo2y ago
This happens for every module, if i delete the apollo config the i18n has the same error after
Fabian B.
Fabian B.2y ago
Okay seems like something is wrong with the types. Can you delete your .nuxt and package lock folder and npm install again? It will regenerate it
> Rodrigo
> Rodrigo2y ago
Yes I did nuxt prepare again to generate it, but will try that way (using turborepo)
Fabian B.
Fabian B.2y ago
yeah sometimes that’s not enough though Okay no experience with turborepo, do you have a regular node_modules folder?
> Rodrigo
> Rodrigo2y ago
yap npm i install regeneration did not work
Fabian B.
Fabian B.2y ago
Okay could you show the whole nuxt Config?
> Rodrigo
> Rodrigo2y ago
import { defineNuxtConfig } from 'nuxt/config'
import { publicConfig, privateConfig } from './lib/config'
// import { http, https } from './lib/net/agents.js'

export default defineNuxtConfig({
modules: [
'@nuxtjs/i18n',
'@nuxtjs/apollo',
'@pinia/nuxt'
],

imports: {
dirs: [
'composables/**'
]
},

// Component auto-imports.
components: [
{
path: '~/components/cms',
extensions: ['.vue'],
prefix: 'CMS'
}
],

vite: {
server: {
proxy: {
'/rodri': {
rewrite: (_: any) => '',
changeOrigin: true,
target: 'something'
}
}
}
},

apollo: {
autoImports: true,
clients: {
default: {
httpEndpoint: 'http://localhost:3000/rodri' // 'https://catalog3-api.dev.worten.net/graphql'
}
}
},

i18n: {
detectBrowserLanguage: false,
defaultLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
strategy: 'no_prefix',
locales: [
'pt-PT',
'es-ES'
],
vueI18n: {
fallbackLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
messages: {
'pt-PT': require('./translations/pt-PT'),
'es-ES': require('./translations/es-ES')
}
}
},

runtimeConfig: {
...privateConfig(),
public: {
...publicConfig()
}
}
})
import { defineNuxtConfig } from 'nuxt/config'
import { publicConfig, privateConfig } from './lib/config'
// import { http, https } from './lib/net/agents.js'

export default defineNuxtConfig({
modules: [
'@nuxtjs/i18n',
'@nuxtjs/apollo',
'@pinia/nuxt'
],

imports: {
dirs: [
'composables/**'
]
},

// Component auto-imports.
components: [
{
path: '~/components/cms',
extensions: ['.vue'],
prefix: 'CMS'
}
],

vite: {
server: {
proxy: {
'/rodri': {
rewrite: (_: any) => '',
changeOrigin: true,
target: 'something'
}
}
}
},

apollo: {
autoImports: true,
clients: {
default: {
httpEndpoint: 'http://localhost:3000/rodri' // 'https://catalog3-api.dev.worten.net/graphql'
}
}
},

i18n: {
detectBrowserLanguage: false,
defaultLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
strategy: 'no_prefix',
locales: [
'pt-PT',
'es-ES'
],
vueI18n: {
fallbackLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
messages: {
'pt-PT': require('./translations/pt-PT'),
'es-ES': require('./translations/es-ES')
}
}
},

runtimeConfig: {
...privateConfig(),
public: {
...publicConfig()
}
}
})
Fabian B.
Fabian B.2y ago
Any reason you import defineNuxtConfig manually? That’s an auto import This is maybe why it doesn’t know about your local types
> Rodrigo
> Rodrigo2y ago
Good catch, I deleted it Will restart the ts server Still has the error
Fabian B.
Fabian B.2y ago
Arg 😄
> Rodrigo
> Rodrigo2y ago
😄
> Rodrigo
> Rodrigo2y ago
No description
> Rodrigo
> Rodrigo2y ago
Is this okay:
No description
> Rodrigo
> Rodrigo2y ago
Not exporting something
Fabian B.
Fabian B.2y ago
I will look into my generated nuxt folder
> Rodrigo
> Rodrigo2y ago
No description
> Rodrigo
> Rodrigo2y ago
This seems all okey The generation
Fabian B.
Fabian B.2y ago
Yeah this file looks similar to mine Think that's okay since it's a d.ts file. So only for types, does not have to export something Hmm let me think 😄 Which nuxt version are you using?
> Rodrigo
> Rodrigo2y ago
I changed IDE's and is not an IDE thing
> Rodrigo
> Rodrigo2y ago
No description
Fabian B.
Fabian B.2y ago
Ah okay that would be my next question. Sometimes I have to restart Volar/the IDE to make TS get in sync again
> Rodrigo
> Rodrigo2y ago
inteliJ gives the same error OMG I found it
Fabian B.
Fabian B.2y ago
You have nuxt/kit installed, so is this a module? tell me 😄
> Rodrigo
> Rodrigo2y ago
Forget it it was a TS server restart noooo! Sorry ahahah
No description
> Rodrigo
> Rodrigo2y ago
No description
> Rodrigo
> Rodrigo2y ago
I removed this And thought it was the solution but was just a restart mb
Fabian B.
Fabian B.2y ago
😂 sometimes it's those things yeah simplest things
> Rodrigo
> Rodrigo2y ago
Im creating modules locally in this nuxt repo so I can use in my app It did not work After restart Still no answer Got all hyped for nothing ahaha
> Rodrigo
> Rodrigo2y ago
My IDE tells me he is searching for nuxtConfig type here:
No description
> Rodrigo
> Rodrigo2y ago
And not the generated ones Maybe this helps
Fabian B.
Fabian B.2y ago
Hm but what you've shown is just the node_modules files, which of course does not contain "custom" project based types like for apollo or i18n
> Rodrigo
> Rodrigo2y ago
Yap
Fabian B.
Fabian B.2y ago
What do you mean by that "My IDE tells me he is searching for nuxtConfig type here:"
> Rodrigo
> Rodrigo2y ago
When I do a Ctrl + click on the NuxtConfig the IDE forwards me there
> Rodrigo
> Rodrigo2y ago
No description
Fabian B.
Fabian B.2y ago
Ah okay Same for me though
Fabian B.
Fabian B.2y ago
Do you also have these files?
No description
No description
> Rodrigo
> Rodrigo2y ago
No description
> Rodrigo
> Rodrigo2y ago
Seems slim compared with yours
Fabian B.
Fabian B.2y ago
Oh you don't, interesting Yeah since these files add typings for the config Can you run nuxt prepare again and see if it generates more?
> Rodrigo
> Rodrigo2y ago
No description
> Rodrigo
> Rodrigo2y ago
No description
> Rodrigo
> Rodrigo2y ago
Same output The modules are on the root node-modules and not this one, maybe could take effect on the output
Fabian B.
Fabian B.2y ago
Yeah that could indeed have an impact... But do the modules work when you start the devserver? so is it just a TS issue?
> Rodrigo
> Rodrigo2y ago
They work, its just a ts issue
Fabian B.
Fabian B.2y ago
// @ts-ignore 😈 no just joking it's wierd that its only generating this one "types" folder Is it generating more when you start the devserver?
> Rodrigo
> Rodrigo2y ago
Ahahah you want to know my "fix": 😈
No description
Fabian B.
Fabian B.2y ago
Hahahaha
> Rodrigo
> Rodrigo2y ago
yap it did
> Rodrigo
> Rodrigo2y ago
No description
Fabian B.
Fabian B.2y ago
okay but no "modules" folder like on my project
> Rodrigo
> Rodrigo2y ago
exactly
Fabian B.
Fabian B.2y ago
If you want maybe you could create a minimal reprod with turborepo, maybe it's a bug with nuxt not recognizing the modules right
> Rodrigo
> Rodrigo2y ago
How do I do that kinda of thing? Code Sandbox?
Fabian B.
Fabian B.2y ago
Nuxt
Reporting Bugs
One of the most valuable roles in open source is taking the time to report bugs helpfully.
Fabian B.
Fabian B.2y ago
It clones an example repo into codesandbox or stackblitz if you click below
> Rodrigo
> Rodrigo2y ago
StackBlitz is super fast damn Reproducing something like what I have seems to work..
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
What is it?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
You ura using i18n in a component?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
i18n: {
detectBrowserLanguage: false,
defaultLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
strategy: 'no_prefix',
locales: [
'pt-PT',
'es-ES'
],
vueI18n: {
fallbackLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
messages: {
'pt-PT': require('./translations/pt-PT'),
'es-ES': require('./translations/es-ES')
}
}
},
i18n: {
detectBrowserLanguage: false,
defaultLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
strategy: 'no_prefix',
locales: [
'pt-PT',
'es-ES'
],
vueI18n: {
fallbackLocale: process.env.DEFAULT_LOCALE ?? 'pt-PT',
messages: {
'pt-PT': require('./translations/pt-PT'),
'es-ES': require('./translations/es-ES')
}
}
},
This seems to be working
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
Its just a folder with a json file like this
> Rodrigo
> Rodrigo2y ago
No description
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
How did you install i18n?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
npm install @nuxtjs/i18n@next --save-dev use this one
> Rodrigo
> Rodrigo2y ago
Nuxt
I18n Module
i18n features for your Nuxt project so you can easily add internationalization.
> Rodrigo
> Rodrigo2y ago
You are using an outdated version that probably is for nuxt 2
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
How did you install nuxt?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
Don't know.. Maybe up the nuxt version? 3.2
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
You welcome!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
Don't get me wrong but thank god.. I was going maniac finding a solution, now atleast I have company 😂 The types are being generated but defineNuxtConfig is not using them Can you reproduce the issue just by installing 2 modules? Would be good to open an issue
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
Nope, I have i18n, apollo and pinia in my case It was working before, but when I moved the project to another folder it stopped working
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
Unnistall for mean removing from defineNuxtConfig modules declaration or npm unninstall?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
Will do tomorrow and reach back to you! Open an issue on this or go to the all chat! Couldnt find the time to test it today, any news?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
It drives me crazy tbh.. Hope I find the time to create an issue. One of my colleagues said it happens on react with vite aswell on certain packages Could be not related tho..
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
> Rodrigo
> Rodrigo2y ago
Makes sense yes Will analyse it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server