Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Error with HttpClient Module in angular

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 {

like image 959
Gajendra Devkate Avatar asked Nov 29 '22 21:11

Gajendra Devkate


2 Answers

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

imports: [  
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    MatToolbarModule,
    FlexLayoutModule,
    HttpClientModule
  ],
like image 162
Thilina Liyanage Avatar answered Dec 15 '22 15:12

Thilina Liyanage


That precisely is, when it comes to importing it should be HttpClientModule and when it comes to usage it should be HttpClient

Reference: https://angular.io/guide/http

like image 45
Prince Sewani Avatar answered Dec 15 '22 16:12

Prince Sewani