I am getting following error: Module '".../node_modules/moment/moment"' has no exported member 'default'
when I use
import * as _moment from 'moment';
import { default as _rollupMoment } from 'moment';
const moment = _rollupMoment || _moment;
You can now use Moment. js in your Angular app, as long as you import it into the component in which you plan to use it.
Moment. js is used for parsing, validating, manipulating, and displaying dates and times in JavaScript. In this guide, we are adding Moment. js to Angular (application platform).
From Moment's Docs:
Note: If you have trouble importing moment, try adding "allowSyntheticDefaultImports": true in compilerOptions in your tsconfig.json file and then use the syntax
That's because moment
does not have something called default
did you mean defaultFormat
?
Also you don't need your second import. You can just say _moment.defaultFormat
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