Dave Dave - 22 days ago 52
TypeScript Question

Ionic 2: How to fix usage of moment.js errors

Since updating to RC.0, I'm getting the following build error to do with moment.js (which I have installed via npm):

[13:44:16] Error: Cannot call a namespace ('moment')

I have tried referencing moment in two ways:

  • import * as moment from 'moment';

  • import moment from 'moment'

The error is the same.

Q) What am I doing wrong? This was working before RC.0


With import * as Moment from 'moment'; I was getting the error: Cannot call a namespace ('Moment').

Changing it to import Moment from 'moment'; resolved the issue.