Angular HttpClientModule error - The declaration was marked as deprecated here

Discussão em 'Angular' iniciado por Gbenga, Janeiro 18, 2025.

  1. Gbenga

    Gbenga Guest

    In Angular-19 no-standalone project I got this error:

    The declaration was marked as deprecated here.

    and HttpClientModule is highlighted in Core.Module

    MAIN CODE:

    App.Module:

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

    import { AppRoutingModule } from './app-routing.module';
    import { AppComponent } from './app.component';
    import { SharedModule } from './shared/shared.module';
    import { BootstrapModule } from './shared/boostrap.module';
    import { CoreModule } from './core/core.module';

    @NgModule({
    declarations: [
    AppComponent
    ],
    imports: [
    BrowserModule,
    AppRoutingModule,
    SharedModule,
    BootstrapModule,
    CoreModule
    ],
    providers: [],
    bootstrap: [AppComponent]
    })
    export class AppModule { }


    Core.Module:

    import { NgModule, Optional, SkipSelf } from '@angular/core';
    import { CommonModule } from '@angular/common';
    import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
    import { JwtInterceptor } from './interceptors/jwt.interceptor';
    import { ErrorInterceptor } from './interceptors/error.interceptor';
    import { LoadingInterceptor } from './interceptors/loading.interceptor';

    @NgModule({
    imports: [
    CommonModule,
    HttpClientModule
    ],
    providers: [
    { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: LoadingInterceptor, multi: true }
    ]
    })
    export class CoreModule {
    constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    if (parentModule) {
    throw new Error('CoreModule is already loaded. Import it in the AppModule only.');
    }
    }
    }


    package.json:

    {
    "name": "smart-spec-makers-uix",
    "version": "0.0.0",
    "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
    },
    "private": true,
    "dependencies": {
    "@angular/animations": "^19.0.0",
    "@angular/common": "^19.0.0",
    "@angular/compiler": "^19.0.0",
    "@angular/core": "^19.0.0",
    "@angular/forms": "^19.0.0",
    "@angular/platform-browser": "^19.0.0",
    "@angular/platform-browser-dynamic": "^19.0.0",
    "@angular/router": "^19.0.0",
    "@auth0/angular-jwt": "^5.2.0",
    "@ng-bootstrap/ng-bootstrap": "^18.0.0",
    "@ngx-translate/core": "^16.0.4",
    "@ngx-translate/http-loader": "^16.0.1",
    "bootstrap": "^5.3.3",
    "bootstrap-icons": "^1.11.3",
    "chart.js": "^4.4.7",
    "ng2-charts": "^8.0.0",
    "ngx-bootstrap": "^19.0.2",
    "ngx-pagination": "^6.0.3",
    "ngx-toastr": "^19.0.0",
    "rxjs": "~7.8.0",
    "sweetalert2": "^11.15.10",
    "tslib": "^2.3.0",
    "zone.js": "~0.15.0"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "^19.0.7",
    "@angular/cli": "^19.0.7",
    "@angular/compiler-cli": "^19.0.0",
    "@types/jasmine": "~5.1.0",
    "jasmine-core": "~5.4.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.6.2"
    }
    }


    I have check the entire code, and could not figure out how to resolve the issue.

    What could be the issue

    kindly help resolve it

    Continue reading...

Compartilhe esta Página