Using both moment and moment tz
11,509
Remove moment
as a separate package in your package.json and reference moment-timezone
whenever you need an instance of the moment object. In fact, if you don't and you're referencing both packages separately, you'll be loading two largely identical versions of moment.
The documentation referenced by @RobG in his comment is correct, it's just that the moment-timezone
package itself loads moment
as a dependency.
Related videos on Youtube
Comments
-
Scipion over 1 year
I have recently added
moment-timezone
to my project. Now that I've started using it, I notice I have replaced nearly all myimport * as moment from "moment"
with
import * as moment from "moment-timezone"
I don't see any reason to keep
moment
around. Is there any limitation I should be aware of before removing it?-
Jaromanda X about 6 yearsdo you use any of moment? we can't tell
-
Scipion about 6 yearsI do, but I was thinking about replacing all my moment by moment-timezone
-
Jaromanda X about 6 yearsdoes importing moment-timezone give you access to moment functions? I don't think it does - I guess the question is, have you tried?
-
Scipion about 6 yearsyes I did, and it seems so, it's why I want to remove moment :)
-
RobG about 6 yearsRead the documentation: "To use moment-timezone, you will need [email protected]+, moment-timezone.js, and the moment-timezone data."
-
-
Jeremy Wiebe over 4 yearsIMHO those docs could be more explicit that you only need to directly depend on one or the other, but not both. :)