"moment" has no exported member 'default'

Amit Golhar picture Amit Golhar · Feb 19, 2019 · Viewed 12.5k times · Source

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;

Answer

dileepkumar jami picture dileepkumar jami · Feb 19, 2019

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