I am working on ionic2
project. I have just start using moment.js
but I have a weird issue.
I have installed in via npm: npm install moment -S
.
Then I have used it in my code:
import moment from 'moment'
...
let x = moment()
debugger
On the console I get this funny issue:
> x
< Moment {_isAMomentObject: true, _isUTC: false, _pf: {…}, _locale: Locale, _d: Wed Jun 27 2018 12:06:23, …}
> y = moment()
< VM770:1 Uncaught ReferenceError: moment is not defined
at eval (eval at Phase (phase.ts:13), <anonymous>:1:1)
at new Phase (phase.ts:13)
at new Stage (stage.ts:10)
at new HomePage (home.ts:39)
at createClass (core.es5.js:10795)
at createDirectiveInstance (core.es5.js:10621)
at createViewNodes (core.es5.js:11971)
at createRootView (core.es5.js:11876)
at callWithDebugContext (core.es5.js:13007)
at Object.debugCreateRootView [as createRootView] (core.es5.js:12468)
Why can't I work with moment within the console?
moment()
is no longer used in this context ("debugger" is the last line), V8 optimized it away in this context, I guess.let y = moment()
after debugger. Same error.node
in the terminal and requiringmoment
in there. This is how I did it.