Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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 {
Maybe you have imported
HttpClient
instead of
HttpClientModule
.
Check imports in
app.module.ts
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatToolbarModule,
FlexLayoutModule,
HttpClientModule
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
I faced Same Issue in AngularJs Version 13:
Error: node_modules/@angular/common/http/http.d.ts:91: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.
Solution : That Error is Our HttpClientModule is Not Import In our
app.module.ts file
Then You Can Add HttpClientModule to imports Area.
@NgModule({
declarations: [AppComponent],
// After import here Above Import API
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
HttpClientModule,
providers: [],
bootstrap: [AppComponent],
export class AppModule {}
I had the same problem, I just ran the following command and it worked for me.
npm cache verify
If it doesn't work, manually delete node_module
and reinstall it.
rm -rf node_modules
npm install
And also you need to add HttpClientModule
just after BrowserModule
. Otherwise, it won't work. See below.
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
BrowserAnimationsModule,
MatToolbarModule,
FlexLayoutModule
The HttpClientModule needs to be imported under @NgModule section. So make sure it is under "imports" as opposed to the "declaration" section. This should resolve the problem as in: imports: [
BrowserModule,
HttpClientModule,
FormsModule,
AppRoutingModule,
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.