Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astro-i18next type error on local builds #197

Open
clee231 opened this issue Jan 15, 2025 · 2 comments
Open

astro-i18next type error on local builds #197

clee231 opened this issue Jan 15, 2025 · 2 comments

Comments

@clee231
Copy link

clee231 commented Jan 15, 2025

I'm trying to build this project locally, however visiting the local dev server after running yarn start:build returns an error regarding the language selector.

23:59:13 [200] /en/ 83ms
23:59:13 [ERROR] Cannot read properties of undefined (reading 'map')
  Stack trace:
    at /home/clee231/works-on-woa/node_modules/astro-i18next/src/components/LanguageSelector.astro:26:19
    at AstroComponentInstance.init (/home/clee231/works-on-woa/node_modules/astro/dist/runtime/server/render/astro/instance.js:33:29)
    at Object.render (/home/clee231/works-on-woa/node_modules/astro/dist/runtime/server/render/component.js:343:22)

I've tried building this project using Node 20 and 21, but both return the same error.

It seems to be referring to this https://github.com/yassinedoghri/astro-i18next/blob/v1.0.0-beta.21/src/components/LanguageSelector.astro#L26, where i18next.languages seems to be not defined. Is there a configuration file that needs to be updated?

@ejadib
Copy link

ejadib commented Jan 17, 2025

Hi @clee231,

It seems the issue arises because the i18next dependency is installed twice:

  • Directly from the package.json
  • Indirectly through the astro-i18next module.

As a result, while i18next.language is configured, the build process is using the incorrect instance of i18next.

To resolve this, you’ll need to remove the i18next dependency bundled with the astro-i18next module and then rebuild the project.

Specifically, delete the following folder: node_modules\astro-i18next\node_modules\i18next

Let me know if this resolves the issue!

@clee231
Copy link
Author

clee231 commented Jan 19, 2025

Hello @ejadib,

Thank you for the in-depth explanation. This does seems resolve the runtime issue! Thank you! 😊

Browsing through the code, I only see a few references to astro-i18next. I'm wondering if removing the astro-i18next dependency and just implementing a LanguageSelector component within this project would be a longterm fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants