bs-moment icon indicating copy to clipboard operation
bs-moment copied to clipboard

Moment.duration is not a function

Open kennetpostigo opened this issue 7 years ago • 3 comments

Hey I ran into this error where the code compiles, but when I check the browser I get an error in the console saying that Moment.duration is not a function. Heres the code

MomentRe.Moment.subtract(
  ~duration=MomentRe.duration(7, `days),
  MomentRe.momentNow()
)

Heres the error: screen shot 2018-02-22 at 10 37 29 am

kennetpostigo avatar Feb 22 '18 15:02 kennetpostigo

Turns out this is b/c moment 1.3.x exports the module differently. So you have to change the moment bindings to use default:

[@bs.module "moment"] external momentNow : unit => t = "default";

I've gone ahead and rolled my own bindings and can confirm this is the way to fix it.

kennetpostigo avatar Feb 22 '18 16:02 kennetpostigo

@kennetpostigo, for now, the expected version of moment is "moment": "^2.20.1" as specified in package.json. You are using an old version. Do you think it is possible for you to upgrade?

If not, probably we need to figure out how to publish dual versioned bindings.

jimexist avatar Feb 23 '18 01:02 jimexist

@Jimexist we have the same problem on my project and we have "moment": "2.22.2". I also created a fork of this and am using that at the moment.

baldurh avatar Feb 12 '19 15:02 baldurh