Error: Unexpected value 'undefined' declared by the module

Dung Do Tien Oct 22 2020 563

I have a project with Angular 8, I have created a component FilterBumpChartComponent but now I don't want to use it more so I comment it in App.module.ts as below :

@NgModule({
    imports: [
        HttpClientModule,
    ],
    declarations: [
        ReportSaleComponent,
        BumpChartComponent,
        //FilterBumpChartComponent
        ,PromotionComponent    

     ],
    entryComponents: [

    ]
})
export class ReportModule { }

But after saving the file I got an error Error: Unexpected value 'undefined' declared by the module 'AppModule' as below :

zone.js:852 Uncaught Error: Uncaught (in promise): Error: Unexpected value 'undefined' declared by the module 'AppModule'
Error: Unexpected value 'undefined' declared by the module 'AppModule'
    at syntaxError (compiler.js:2409)
    at compiler.js:20778
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:20776)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (compiler.js:26865)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:26846)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync (compiler.js:26806)
    at CompilerImpl.push../node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js.CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:143)
    at MergeMapSubscriber.project (router.js:3617)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:61)
    at resolvePromise (zone.js:852)
    at resolvePromise (zone.js:809)
    at zone.js:913
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:24328)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)
resolvePromise @ zone.js:852
resolvePromise @ zone.js:809
(anonymous) @ zone.js:913
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:423
onInvokeTask @ core.js:24328
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:422
push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:195
drainMicroTaskQueue @ zone.js:601

I don't know why. Please suggest to me if you know the reason.

Have 3 answer(s) found.
  • M

    Manish Kumar Oct 22 2020

    I see in your  App.module.ts file you have two ,,  in declarations array. 

    Try to do as below : 

     declarations: [
    	ReportSaleComponent,
    	BumpChartComponent
    	//FilterBumpChartComponent
    	,PromotionComponent    
     ] 

    It will resolve the bug for you.

  • M

    Marry Christ Oct 22 2020

    I just got the same error, sometimes this issue occurs and you only need to re-run the server using ng serve or whatever CLI you use.

  • S

    Sandeep Kumar Oct 22 2020

    Try this may help you:
    Re-start the ng serve service. Now the page could navigate.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close