2

I was updating my self-answer to Filter out non-contiguous date using momentjs and twix.js and tried to make use of Stack Snippets, but it's not working.

I'm trying to understand if the Moment.js plugin is broken, I'm doing something wrong, or Stack Snippets aren't behaving as intended (or the setup of my work laptop/Internet proxy has broken something else).

The error I get in the snippet console is:

{
  "message": "Uncaught TypeError: moment(...).twix is not a function",
  "filename": "https://stacksnippets.net/js",
  "lineno": 25,
  "colno": 43
}

And in the developer console:

Uncaught TypeError: Cannot set properties of undefined (setting '_twix') at Function.Twix._extend (twix.min.js:1) at makeTwix (twix.min.js:1) at twix.min.js:1 at twix.min.js:1

Which, I could have sworn, was not there last night. It might hint this is not a snippet problem.

6
  • 1
    Possibly related: meta.stackoverflow.com/q/413126/6296561 Commented Nov 17, 2021 at 11:41
  • Yes, the twix library also fails to initialise. Throws an error because first is undefined. But I don't see a good reason it should be right now. EDIT: Twix._extend(moment._locale, { _twix: Twix.defaults }); seems to be a aproblem because moment._locale is undefined. Perhaps the source of moment needs to include that? Dunno.
    – VLAZ
    Commented Nov 17, 2021 at 11:49
  • @VLAZ it exists in the codebase for moment, but I've not dug into if it would be accessible in the way twix seems to assume it is Commented Nov 17, 2021 at 11:53
  • The version of twix.js you use seems quite old (now they are at 1.3.0). Updating it it will merge correctly with moment.js, leaving only a TypeError about range.start.unix being undefined, but that error comes from your code. (I don't know twix.js to know if there should be such a property or not).
    – Kaiido
    Commented Nov 17, 2021 at 14:34
  • 1
    @Kaiido that fixed it, I assumed the cdn would default to the latest version Commented Nov 17, 2021 at 15:18
  • I've deleted the answer as it's currently incorrect for the recent version of twix Commented Nov 17, 2021 at 15:18

0

You must log in to answer this question.

Browse other questions tagged .