Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 TypeError: Cannot read property 'call' of undefined

Tags:

angular

I am trying to migrate the angular app from 5 to 6 version. The app is running well but if I do some changes in my code after page reloading, I am facing a weird error:

core.js:1598 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/secure/dashboard/member-index/member-index.module.ngfactory.js (member-index.component.ts:33)
    at __webpack_require__ (bootstrap:81)
    at $_lazy_route_resource lazy namespace object:56
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
    at Object.onInvoke (core.js:4062)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
    at zone.js:872
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/secure/dashboard/member-index/member-index.module.ngfactory.js (member-index.component.ts:33)
    at __webpack_require__ (bootstrap:81)
    at $_lazy_route_resource lazy namespace object:56
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
    at Object.onInvoke (core.js:4062)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
    at zone.js:872
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    at zone.js:873
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4053)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)

Did someone face this error? Why this error appears after code changing?

UPD

I was using ng serve --aol to run my app. If I use ng serve the error disappears

like image 960
Dmitry Grinko Avatar asked May 16 '18 15:05

Dmitry Grinko


2 Answers

I think it happens when you make changes to module imports during run time.

Run the application again using ng serve and it fixed the issue for me.

It may also occur when you try to use components of lazy loaded modules in other modules before the lazy module getting loaded or such similar scenarios.

like image 59
Franklin Pious Avatar answered Nov 04 '22 19:11

Franklin Pious


Issue FIXED by angular-cli team, you just need to update your "webpack": "^4.15.1" Good luck.

This was my earlier answer.

This is an open-label:comp: devkit/build-angular issue in angular-cli.

Yes, you are right in the ng serve you don't see the error. Even I faced the same error while developing my application, I did end my ng serve and tried again, it worked and the ng build --prod is also successful. Please refer to the below-provided link, you will get to know more on this.

https://github.com/angular/angular-cli/issues/11129

like image 30
Manoj Avatar answered Nov 04 '22 18:11

Manoj