angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

resolved __WEBPACK_IMPORTED_MODULE_ moment__ is not a function

Open MatteoNY opened this issue 9 years ago • 10 comments

Issue with Moment.js with webpack on PC Win 7. All was fine on my Mac but when I updated on PC Webpack complained at run time with an error that moment was not a function. I was able to resolve on my PC using import * as moment from 'moment/moment.js'; It was a last hack attempt but it worked for me.

Ran simple test in constructor: const today: string = moment().format('D MMM YYYY'); console.log ('today?', today);

The Angular cli will compile fine but when you visit your website it will fail with webpack error. I also went back a version to 1.4.4 and up to the latest CLI beta and it did not resolve the issue. Just wanted to report that this worked for me. I hope it helps.

@angular/cli: 1.4.5 node: 8.1.4 os: win32 x64 @angular/animations: 4.4.4 @angular/cdk: 2.0.0-beta.12 @angular/common: 4.4.4 @angular/compiler: 4.4.4 @angular/core: 4.4.4 @angular/forms: 4.4.4 @angular/http: 4.4.4 @angular/material: 2.0.0-beta.12 @angular/platform-browser: 4.4.4 @angular/platform-browser-dynamic: 4.4.4 @angular/router: 4.4.4 @angular/cli: 1.4.5 @angular/compiler-cli: 4.4.4 @angular/language-service: 4.4.4 typescript: 2.3.4

MatteoNY avatar Oct 10 '17 15:10 MatteoNY

WEBPACK_IMPORTED_MODULE_0_moment is not a function I got this issue too, have you had solution yet?

huyjack178 avatar Oct 11 '17 06:10 huyjack178

Heya, this sounds odd and I'd like to investigate it.

Can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

filipesilva avatar Oct 11 '17 09:10 filipesilva

Hi, same here: ERROR TypeError: WEBPACK_IMPORTED_MODULE_4_moment is not a function

ruimserrano avatar Oct 11 '17 10:10 ruimserrano

I got a different error related to moment.js. This issue indicates that going back to moment version 2.18.0, instead of 2.19.0, is a solution. https://github.com/moment/moment/issues/2979

sublime392 avatar Oct 11 '17 14:10 sublime392

i degraded to moment 2.18.0 and it fixed

ruimserrano avatar Oct 11 '17 15:10 ruimserrano

moment 2.19.1 fixes the broken 2.19.0 version

chcaru avatar Oct 11 '17 22:10 chcaru

Upgrading to 2.19.1 fixes the issue for me

dantelent avatar Oct 12 '17 08:10 dantelent

Upgrading to 2.19.1 fixes the issue for me too. Thanks everybody

ruimserrano avatar Oct 12 '17 13:10 ruimserrano

I'm sorry, but this issue is not caused by Angular CLI. Please contact the author(s) of the moment project or file an issue on their issue tracker.

alan-agius4 avatar Sep 03 '18 06:09 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.