Sunday, October 13, 2019

Unexpected value '[object Object]' declared by the module 'AppModule'

Hi Guys ,

This blog is about the error " Unexpected value '[object Object]' declared by the module 'AppModule'" .

Error in the page :

Error in /turbo_modules/@angular/compiler@8.2.10/bundles/compiler.umd.js (2603:21)
Unexpected value '[object Object]' declared by the module 'AppModule'

Error in the console :


Error: Unexpected value '[object Object]' declared by the module 'AppModule'
at syntaxError (util.ts:100)
    at eval (metadata_resolver.ts:603)
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.getNgModuleMetadata (metadata_resolver.ts:600)
    at JitCompiler._loadModules (compiler.ts:127)
    at JitCompiler._compileModuleAndComponents (compiler.ts:107)
    at JitCompiler.compileModuleAsync (compiler.ts:61)
    at CompilerImpl.compileModuleAsync (compiler_factory.ts:58)
    at compileNgModuleFactory__PRE_R3__ (application_ref.ts:50)
    at PlatformRef.bootstrapModule (application_ref.ts:307)


We faced this error due while updating declarations in app.module.ts .

Lets see the erroneous code .

@NgModule({
  imports:      [ BrowserModule, FormsModule ,  AngularFireModule.initializeApp(environment.firebase)],
  declarations: [ AppComponent,
  AngularFireModule.initializeApp(environment.firebase),
   HelloComponent, SubjectComponent ],
  bootstrap:    [ AppComponent ],
  providers: [QuizService , AngularFirestore]
}) 


check the declarations part regarding the issue , remove    AngularFireModule.initializeApp(environment.firebase),th e from declarations .

Working code :


@NgModule({
  imports:      [ BrowserModule, FormsModule ,  AngularFireModule.initializeApp(environment.firebase)],
  declarations: [ AppComponent,
  
   HelloComponent, SubjectComponent ],
  bootstrap:    [ AppComponent ],
  providers: [QuizService , AngularFirestore]
})

Hope this helps . Thanks ! .

No comments:

Post a Comment

ec2-user@ec2 Permission denied