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

import moment from 'moment-timezone'; import 'moment/min/locales'; not working #1078

Closed
rendomnet opened this issue Oct 28, 2023 · 5 comments

Comments

@rendomnet
Copy link

Environment

{
"moment": "2.29.4",
"momentTz": "0.5.43",
"date": "Sat Oct 28 2023 16:45:48 GMT+0600 (East Kazakhstan Time)",
"intlZone": "Asia/Almaty"
}

Issue description

import moment from 'moment-timezone';
import 'moment/min/locales';

the locales do not load. But if I use

import moment from 'moment';
import 'moment/min/locales';

then it works

@gilmoreorless
Copy link
Member

Usually situations like this are caused by accidentally having 2 different copies of moment somewhere in the dependency tree. See the "npm" and/or "yarn" sections at #982 (comment) for tips to verify if that's the problem (and how to fix it).

@rendomnet
Copy link
Author

@gilmoreorless
I have only this

    "moment": "^2.29.4",
    "moment-timezone": "^0.5.43",

@gilmoreorless
Copy link
Member

What's specified in package.json is only part of the story. As #982 (comment) explains, what matters is how the dependencies are actually installed in node_modules. moment-timezone could be depending on a version of moment that's different from the one you've specified.

This is something I'm hoping to solve by moving moment to be a peer dependency of moment-timezone (#1039 (comment)).

@rendomnet
Copy link
Author

I've completely removed the 'node_modules' directory and reinstalled it, but the issue still persists. Do I need to have "moment" for 'moment-timezone' to have the necessary locale files? Are they compatible?

@gilmoreorless
Copy link
Member

If there's a lockfile like package-lock.json or yarn.lock that's storing the duplicate versions, removing node_modules won't fix the problem. I've already linked to better explanations of how to diagnose and fix this.

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