Read the statement by Michael Teeuw here.
Do you need to list moment and moment-timezone as dependencies in modules?
-
I maintain a couple modules that depend on the moment or moment-timezone dependency. I had always listed those in package.json and asked users to npm install them.
But I just took over another module that I found relies on moment without installing it at the module level. The only reason I found this out is that I was working on something and got an error message that the module was looking for moment in the parent directory (/home/mmuser/MagicMirror/node_modules/moment/moment.js:2613:19).
So, do I really need to ask users to install moment and/or moment-timezone, or is it safe to simply rely on the installation that comes with the the MagicMirror application itself??
-
P.S. I did test it, and it seems to work with moment-timezone as well.
-
@dathbe you should list them , we can change the base at any time. there have been discussions to move away from moment.
we moved away from request, and etc,etc…
if you do require(x)
then you should list x in package.json -
I underline Sam’s answer. Since moment is no longer being actively developed and the Temporal API is on the horizon, I’m pretty sure
moment
will be replaced at some point. -
@KristjanESPERANTO I’ve noticed that it seems that most of the functions of moment is in vanilla javascript - at least in what we typically use.
-
@KristjanESPERANTO - while true, I also plan to replace moment when temporal is available
-
@BKeyport I couldn’t get timezones working properly. So, for example, if you want to know what day it is, and you’re not on UTC, you’re liable to pull tomorrow’s date. Maybe I don’t know how to do it, but moment is pretty lightweight and makes a few things slightly easier.
-
@dathbe you need moment.timezone
-
@sdetweil Maybe I’m wrong, and I haven’t spent a lot of time trying to test it, but I think regular moment will grab the date in the local timezone based on what is set in the system. You can’t do as much with OTHER timezones in regular moment, but I think at least that works. Whereas the regular javascript
date
will pull the date and time in UTC. That said, I do use moment-timezone in my modules–though some of them I have taken over maintaining, and they used regular moment to some success.