簡體   English   中英

錯誤 NG6002:出現在 AppModule 的 NgModule.imports 中,但無法解析為 NgModule class。 是否缺少@NgModule 注釋?

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

我在我的超級簡單 Angular 應用程序中收到此錯誤,我不知道為什么會收到此錯誤。 我提供了一個屏幕截圖,可以回答您可能遇到的大多數問題。

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

在此處輸入圖像描述

注意:當我第一次生成 ChannelService class 時,它正在編譯,但在我擺弄它后停止工作。 我嘗試了一些顯而易見的事情,比如刪除node_modules和重建。

您的模塊導入中有一個服務,它是一個提供者,應該自動注冊,因為它providedIn: 'root'

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM