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

i18next version 23.0.0 or higher includes breaking changes. #171

Open
izyuumi opened this issue Aug 7, 2023 · 13 comments
Open

i18next version 23.0.0 or higher includes breaking changes. #171

izyuumi opened this issue Aug 7, 2023 · 13 comments

Comments

@izyuumi
Copy link

izyuumi commented Aug 7, 2023

Describe the bug

When using the HeadHrefLangs component with import { HeadHrefLangs } from "astro-i18next/components";, I get a type error: “Cannot read properties of undefined (reading 'map')” when running npm run dev.
However, there are no error thrown when using npm run preview.

SUPPLEMENT:
As per #171 (comment), the main issue was with the use of version that is higher than 22.x.x, which included breaking changes. By using a version less than 23.0.0, npm run dev works as expected.

To Reproduce

Steps to reproduce the behavior:

  1. import the HeadHrefLangs component and use it in pages/index.astro
  2. run npm run dev
  3. go to localhost:3000 (or wherever the page is hosted locally)

Expected behavior

No error to be thrown.

Screenshots

If applicable, add screenshots to help explain your problem.

CleanShot 20230807 100649

Context (please complete the following information):

  • astro-i18next version: 1.0.0-beta.21
  • astro version: 2.10.1
  • OS: MacOS 13.5
  • Browser: tested with Arc, Chrome, Firefox, and Safari
@dluciano
Copy link

dluciano commented Aug 8, 2023

workaround:

rm -rf node_modules && pnpm i --shamefully-hoist=true

@izyuumi
Copy link
Author

izyuumi commented Aug 9, 2023

I am still getting the same error.

@dluciano
Copy link

dluciano commented Aug 9, 2023

I am still getting the same error.

You could try adding a .npmrc file in the root directory of your project and then run

rm -rf node_modules && pnpm install

That worked for me.

@izyuumi
Copy link
Author

izyuumi commented Aug 10, 2023

Thank you for the suggestion.

Do I need to put anything inside the .npmrc file? I created an empty .npmrc file, and ran the command, but it did not work.

@xerullian
Copy link

Yes, put the below in your .npmrc file. This works for me.

# Expose Astro dependencies for `pnpm` users
shamefully-hoist=true

@izyuumi
Copy link
Author

izyuumi commented Aug 30, 2023

Thank you for the detail.
It is still throwing the same error.
The code I am using is https://github.com/onekiji/onekiji. I clone the repo onto my local computer, create .npmrc with shamefully-hoist=true as the content, run pnpm i, and run pnpm dev, and the error message is still present.
Any help is appreciated.

@ZerdoX-x
Copy link
Contributor

ZerdoX-x commented Sep 2, 2023

@xerullian which versions of i18next and astro-i18next are you using?

By experimenting with versions and reading changelog I found out that upgrading [email protected] (latest v22 release) to 23.0.0 leads to breaking latest astro-i18next (and probably all versions) when using pnpm (I haven't tested other managers tho)

@aapl-yumi I also could not make all of them work together by configuring pnpm. You can delete .npmrc and downgrade i18next as mentioned above. And could you please update issue's title and description according to this? We have exact information and even commits which break astro-i18next. Also please mention current workaround. Thank you.

@izyuumi
Copy link
Author

izyuumi commented Sep 2, 2023

@ZerdoX-x Thank you very much for your suggestion on downgrading. I was fiddling around with astro-i18next, but not i18next. I just downgraded i18next to [email protected], and pnpm dev works as expected.
Furthermore, I will alter the title and description to regard the issues with the version.

@izyuumi izyuumi changed the title Cannot read properties of undefined (reading 'map') when using HeadHrefLangs component i18next version 23.0.0 or higher includes breaking changes. Sep 2, 2023
@izyuumi izyuumi closed this as completed Sep 2, 2023
@ZerdoX-x
Copy link
Contributor

ZerdoX-x commented Sep 2, 2023

Please reopen

@calmonr
Copy link

calmonr commented Sep 2, 2023

I'm using the latest (v23.4.6) i18next version and I have a local component exactly like HeadHrefLangs from astro-i18next. For some reason the problem only happens when importing from astro-i18next, if you have the component locally it will work.

@ZerdoX-x
Copy link
Contributor

ZerdoX-x commented Sep 2, 2023

@calmonr because it's related to pnpm and how it's managing node_modules.

@ZerdoX-x
Copy link
Contributor

@aapl-yumi would you like to reopen issue? if not, i'll just reopen this issue in separate one

@izyuumi izyuumi reopened this Sep 14, 2023
@webvs2
Copy link

webvs2 commented Feb 19, 2024

image
Please consider trying this configuration. I have also encountered a similar issue when using the 'LanguageSelector' component, which resulted in a 'map' error from the 'i18next.languages'. By reducing the i18next version to 22, this configuration eliminates the error. I hope this solution proves helpful to everyone.

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

6 participants