MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Do you need to list moment and moment-timezone as dependencies in modules?

    Scheduled Pinned Locked Moved Development
    9 Posts 4 Posters 626 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      dathbe
      last edited by

      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??

      D S 2 Replies Last reply Reply Quote 0
      • D Offline
        dathbe @dathbe
        last edited by

        P.S. I did test it, and it seems to work with moment-timezone as well.

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil @dathbe
          last edited by sdetweil

          @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

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          KristjanESPERANTOK 1 Reply Last reply Reply Quote 2
          • KristjanESPERANTOK Offline
            KristjanESPERANTO Module Developer @sdetweil
            last edited by

            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.

            BKeyportB D 2 Replies Last reply Reply Quote 0
            • BKeyportB Online
              BKeyport Module Developer @KristjanESPERANTO
              last edited by

              @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.

              The "E" in "Javascript" stands for "Easy"

              D 1 Reply Last reply Reply Quote 1
              • D Offline
                dathbe @KristjanESPERANTO
                last edited by

                @KristjanESPERANTO - while true, I also plan to replace moment when temporal is available

                1 Reply Last reply Reply Quote 1
                • D Offline
                  dathbe @BKeyport
                  last edited by

                  @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.

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @dathbe
                    last edited by

                    @dathbe you need moment.timezone

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    D 1 Reply Last reply Reply Quote 1
                    • D Offline
                      dathbe @sdetweil
                      last edited by

                      @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.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy