#Help with HttpClientModule Giving error when imported in AppModule

11 messages · Page 1 of 1 (latest)

rugged ledge
#

Hello guys, I was trying to import HttpClientModule in AppModule but i am getting this Error

    ERROR in node_modules/@angular/common/http/http.d.ts:2801: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 HttpClientModule 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.

Here's my AppModule code:

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

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
import { HomeComponent } from './home/home.component';
import { HeaderComponent } from './header/header.component';
import { MovieComponent } from './movie/movie.component';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    HomeComponent,
    HeaderComponent,
    MovieComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    AppRoutingModule,
    FormsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Angular version: 9

umbral lance
#

What is the output of ng v when running it from inside the directory of that project?

rugged ledge
#

9.0.7

umbral lance
#

The full ouptut.

rugged ledge
#

and node is 16.19.0

#

Angular CLI: 9.0.7
Node: 16.19.0
OS: linux x64

Angular: 9.0.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.7
@angular-devkit/build-angular     0.900.7
@angular-devkit/build-optimizer   0.900.7
@angular-devkit/build-webpack     0.900.7
@angular-devkit/core              9.0.7
@angular-devkit/schematics        9.0.7
@ngtools/webpack                  9.0.7
@schematics/angular               9.0.7
@schematics/update                0.900.7
rxjs                              6.5.5
typescript                        3.7.7
webpack                           4.41.2
umbral lance
#

Angular 9 is 3 years old. Why are you using such an old version for what I assume is a new project?

rugged ledge
#

I am learning it for the workplace... Angular there is version 9...

umbral lance
#

So you're learning obsolete stuff? The version of Node compatible with that obsolete release is 10.

rugged ledge
#

Well, kinda yeah 😅 alright thanks i will try it on node 10

umbral lance
#

If you're learning for the workplace, IMHO, you should get mentored by someone in the workplace. Especially if they have questionable requirements.