Getting Error with HttpClient Module in angular

Gajendra Devkate picture Gajendra Devkate · Apr 8, 2020 · Viewed 7.7k times · Source

ERROR in node_modules/@angular/common/http/http.d.ts:81:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the library (@angular/common/http) which declares HttpClient has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

81 export declare class HttpClient {

Answer

Thilina Liyanage picture Thilina Liyanage · May 1, 2020

Maybe you have imported HttpClient instead ofHttpClientModule. Check imports in app.module.ts

imports: [  
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    MatToolbarModule,
    FlexLayoutModule,
    HttpClientModule
  ],