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

[Nuxt3] moment.locale not set new locale #6109

Open
ideafm opened this issue Mar 20, 2023 · 5 comments
Open

[Nuxt3] moment.locale not set new locale #6109

ideafm opened this issue Mar 20, 2023 · 5 comments

Comments

@ideafm
Copy link

ideafm commented Mar 20, 2023

Describe the bug
moment.locale not set new locale, instead of this it always return 'en'
UPD: It seems in ssr mode it works fine, but on client is not

To Reproduce
https://stackblitz.com/edit/nuxt-starter-fy3grx?file=app.vue

@Gamblt
Copy link

Gamblt commented Apr 24, 2023

Have the same issue. Any solutions?

@halwesit
Copy link

halwesit commented May 9, 2023

import the locale you want
like:

import 'moment/dist/locale/ru';
moment.locale('ru');

@Talla2XLC
Copy link

import the locale you want like:

import 'moment/dist/locale/ru';
moment.locale('ru');

Got error importing locale from dist folder:
export default hooks;
^^^^^^

SyntaxError: Unexpected token 'export'

@jorge-vnarvaez
Copy link

jorge-vnarvaez commented Nov 5, 2023

For those that are experiencing the SyntaxError: Unexpected token 'export', make sure to add the file extension at the end of import.

In my case was

import 'moment/dist/locale/es.js';
moment.locale('es');

If you still have the same error, go to node_modules/moment/dist/locale and check the extension is mjs or js

@rivz-a
Copy link

rivz-a commented Jan 18, 2024

The following helped when using Nuxt 3:

import moment from 'moment'
import 'moment/dist/locale/ru.js'

moment.updateLocale('ru', null)

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