angulartypescriptmomentjsangular7angular-moment

"moment" has no exported member 'default'


I'm using moment.js to change the local date format for my application but getting the following error:

"moment" has no exported member 'default' when importing the library.

Below is my code:

import {Inject, Injectable, Optional} from '@angular/core';
import {DateAdapter, MAT_DATE_LOCALE, MatDateFormats} from '@angular/material';
import * as _moment from 'moment';
import {default as _rollupMoment, Moment} from 'moment';

const moment = _rollupMoment || _moment;

Solution

  • Try adding "allowSyntheticDefaultImports": true to your tsconfig.json under the "compilerOptions"