Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Angular Error: error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

22.01.2021 (👁1789)

Angular Error: error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

 

 

Error at:

Error: 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 {

 

 

Problem

In app.modules.ts

import { HttpClient } from '@angular/common/http';

and

  imports: [

    BrowserModule,

    HttpClient,

 

 

Solution:

Use HttpClientModule in app.modules.ts

import { HttpClientModule } from '@angular/common/http';

 

And

  imports: [

    BrowserModule,

    HttpClientModule,

 

 

AND stop ng serve with ctrl+c and clean the npm serve cache in powershell Terminal and start it again

Ctrl+c

npm cache clean –force

ng serve

 

 

App.module.tsàError

import { HttpClient } from '@angular/common/http';

import { BehaviorSubject } from 'rxjs';

@NgModule({

  declarations: [

    AppComponent,

    NavbarComponent,

    ListTimeRecordsComponent

  ],

  imports: [

    BrowserModule,

    AppRoutingModule,

    HttpClient,

    BehaviorSubject

  ],

Lösung

Man muss anstatt httpClient das HttpClientModule in app.modules.ts installieren und ng serve stoppen und erneut starten oder sogar npm cache clean --force

 

Ok:

app.modules.ts

import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { TimerecordsService } from "./services/timerecords.service";

 

import { AppRoutingModule } from './app-routing.module';

//import { HttpClient } from '@angular/common/http';

import { HttpClientModule } from '@angular/common/http';

import { BehaviorSubject } from 'rxjs';

import { AppComponent } from './app.component';

import { NavbarComponent } from './components/navbar/navbar.component';

import { ListTimeRecordsComponent } from './components/list-time-records/list-time-records.component';



@NgModule({

  declarations: [

    AppComponent,

    NavbarComponent,

    ListTimeRecordsComponent

  ],

  imports: [

    BrowserModule,

    HttpClientModule,

    AppRoutingModule,    

    BehaviorSubject

  ],

  providers: [TimerecordsService],

  bootstrap: [AppComponent]

})

export class AppModule { }