简体   繁体   中英

error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class. Is it missing an @NgModule annotation?

I am getting this error in my super simple Angular app and I do not know why I am getting this error. I a providing a screenshot that should answer most questions you might have.

error NG6002: Appears in the NgModule.imports of AppModule, but could not be 
  resolved to an NgModule class.
    Is it missing an @NgModule annotation?

在此处输入图像描述

NOTE: When I first generated the ChannelService class, it was compiling, but stopped working after I fiddled around with it. I tried the obvious things like deleting node_modules and rebuilding.

You have a service in your module imports, it is a provider and should be automatically registered because it is providedIn: 'root'

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    HttpClientModule,
    ChannelService, // <-- remove this
    BrowserModule,
    AgGridModule.withComponents([])
  ],
  providers: [],
  bootstrap: [AppComponent]
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM