In my project.clj I've defined the dependency
[cljsjs/moment "2.10.6-0"]
and I'm requiring it in my cljs file using
(:require [cljsjs.moment :as m])
I try and use it like this
(m/from-now 3485736776)
But it says Uncaught ReferenceError: cljsjs is not defined
I also tried
(m/fromNow 3485736776)
Just in case the function call was wrong, but I get the same error ... any ideas?
There's a explanation in cljsjs's wiki page => A Quick JavaScript Interoperability Refresher
basically, require
cljsjs's package without :as
or :refer
. and the library--moment
in your case, available in js
global namespace. Here is a example from my cljs repl:
(require '[cljsjs.moment])
;;=> nil
(js/moment)
;;=> #object[Moment Sat Oct 24 2015 04:29:19 GMT+0700]
(.fromNow (js/moment) 3485736776)
;;=>"a few seconds"
In (:require [cljsjs.moment :as m])
remove the :as m
and that should work. After this the functions in moment
will appear under js/
.
See https://github.com/cljsjs/packages/wiki/Using-Packages for an example using cljsjs.Showdown
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With