Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
191
rated 0 times [  194] [ 3]  / answers: 1 / hits: 15785  / 8 Years ago, wed, april 27, 2016, 12:00:00

I am trying to use moment in my TypeScript project but when I use the line,



import moment from 'moment';


I get the error:




'node_modules/moment/moment' has no default export.




I have also tried,



import moment from 'moment/src/moment';


but then I get the error:




'Cannot find module moment/src/moment'.




Does anybody know a way of doing this? Thanks.


More From » typescript

 Answers
5

The correct syntax is:



import * as moment from 'moment';

[#62382] Monday, April 25, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daryldeontaeh

Total Points: 46
Total Questions: 97
Total Answers: 105

Location: Maldives
Member since Sat, Jan 29, 2022
2 Years ago
;