Moment.js library "format is not a function" error
IdoPrinc3 opened this issue · comments
issue
MMM-OnSpotify/utils/SpotifyDomBuilder.js
Lines 769 to 771 in d0db7ca
Uncaught (in promise) TypeError: moment.duration(...).format is not a function
I had problems with the "format"" function, telling me it didn't exists
so I changed it to "utc" instead of "duration".
My Fix
const lg = moment.utc(n).format("mm:ss");
const fl = moment.utc(t).format("mm:ss");
packages version
npm list --depth=0
mmm-onspotify@2.3.1 /home/ido/MagicMirror/modules/MMM-OnSpotify
├── body-parser@1.20.2
├── cookie-parser@1.4.6
├── dompurify@3.0.5
├── express@4.18.2
├── moment-duration-format@2.3.2
├── moment@2.29.4
├── node-fetch@2.7.0
├── querystring@0.2.1
└── request@2.88.2
Hi, thanks for the input, after reading a bit I think that the problem is the time that MM2 takes in loading the libraries, as moment-duration-format depends on moment. As suggested by a couple of stackoverflow threads adding
import momentDurationFormatSetup from 'moment-duration-format'; momentDurationFormatSetup(moment);
maybe solves the issue. I'm going to try to use .utc() to see if the problem persist, but I'm probably going to change to a function to convert the time without using a dependency just for that.