After upgrading to Angular 18 I get following error when using moment.
Calling "moment" will crash at run-time because it's an import namespace object, not a function
My import statement looks as following
import * as moment from 'moment';
using moment looks like this
moment(this.to.val, this.validTimeFormats, true).isValid()
Any help?
When updating to version 18 angular adds esModuleInterop to the tsconfig.json
https://www.typescriptlang.org/tsconfig/#esModuleInterop
According to documentation either remove it or import moment as
import moment from 'moment';
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