i18n: yarn build generate a prerender nitro error while yarn dev works fine
I wanna deploy my Nuxt 3 app but I get this error although I can run yarn preview but the i18n translation isn’t working.
when running yarn build and yarn preview, error I get on the console in the browser:
When I run yarn build
i18n.config.ts:
nuxt.config.ts:
package.json
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 5
- Comments: 21
Hi @ineshbose here is a reproduction of the error: https://stackblitz.com/edit/github-7hsxua?file=app.vue
Thank you 🙏
From v8.0.0-beta.12, we need to add “type”: “module” to package.json of your nuxt project. https://v8.i18n.nuxtjs.org/getting-started/setup#packagejson
We are working on improving the system so that it can work without the “type”: “module” specification, but at the moment that configuration is required.
Actually this is what I’m experiencing. SSR rendering of translations is not working properly in netlify/vercel. Error has disappeared btw by adding type module, so I guess we should open another issue.
Unfortunately, I had to roll back to the old versions where everything was working fine here are these versions that work for me
@nuxtjs/i18n@8.0.0-beta.11nuxt@3.4.0hope this helps for now till this gets solved in future updates.@kazupon Thank you! while I had followed this suggestion from stackoverflow about a week ago and it makes i18n work… translation still doesn’t work with JavaScript off which is very important for SEO and search indexing. Any ideas why is that?
here is a vercel build: vercel build that can be used to illustrate it along with Disable Javascript Chrome Extension
Issue 1:
I added the following plugin (in addition to the i18n.config.js) and it now translation works without JavaScript enabled BUT lang switcher is not working so I cannot change languages (url changes with adding /en and then it doesn’t remove it for greek language) … there is need for documentation improvement I guess or it should somehow work out of the box without an extra plugin… not sure about langswitcher …
i18n.server.js
LangSwitcher.vue
Issue 2:
I found another issue when javascript is off:
in the data store (pinia) in one of the methods I am doing
and this part is not translated with javascript off
You can check again with this different vercel build (after introducing i18n.server.js plugin) along with Disable Javascript Chrome Extension to see how lang switcher doesn’t behave properly with javascript off