Error: Unable to instantiate NGXLoggerHttpService due to an issue with the HttpBackend injection in the AppModule

I encountered an error message after updating my NgxLogger module:

main.ts:17 NullInjectorError: StaticInjectorError(AppModule)[NGXLoggerHttpService -> HttpBackend]: 
  StaticInjectorError(Platform: core)[NGXLoggerHttpService -> HttpBackend]: 
    NullInjectorError: No provider for HttpBackend!

main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { RecaptchaComponent } from 'ng-recaptcha';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule).then(ref => {
  if (window['ngRef']) {
    window['ngRef'].destroy();
  }
  window['ngRef'] = ref;
}).catch(err => console.error(err));

RecaptchaComponent.prototype.ngOnDestroy = function () {
  if (this.subscription) {
    this.subscription.unsubscribe();
  }
};

core.module.ts

import { NgModule } from '@angular/core';
import { environment } from 'src/environments/environment';
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { BrowserModule } from '@angular/platform-browser';
import { AngularFireDatabaseModule } from '@angular/fire/database';
import { StoreModule } from '@ngrx/store';
import { metaReducers, reducers } from './core.state';
import { EffectsModule } from '@ngrx/effects';
import { AuthEffects } from '../modules/auth/auth.effects';
import { CustomNGXLoggerService, LoggerModule, NGXLogger, NGXLoggerHttpService } from 'ngx-logger';

@NgModule({
  imports: [
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFirestoreModule,
    AngularFireDatabaseModule,
    AngularFireAuthModule,
    BrowserModule,
    StoreModule.forRoot(reducers, {
      metaReducers,
      runtimeChecks: {
        strictActionImmutability: true,
        strictStateImmutability: true,
      },
    }),
    EffectsModule.forRoot([
      AuthEffects
    ]),
  ],
  providers: [
    NGXLogger,
    NGXLoggerHttpService,
    CustomNGXLoggerService
  ]
})

export class CoreModule {
}

app.module.ts

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AuthService } from './modules/auth/auth.service';
import { ReferralService } from './modules/referral/referral.service';
import { UserService } from './modules/shared/services/user.service';
import { UtilService } from './modules/shared/services/util.service';
import { CoreModule } from './core/core.module';
import { NavbarModule } from './modules/shared/components/navbar/navbar.module';
import { FooterModule } from './modules/shared/components/footer/footer.module';
import { NgxUiLoaderModule } from 'ngx-ui-loader';
import { RouterModule, Routes } from '@angular/router';
import { LoggerModule } from 'ngx-logger';
import { environment } from '../environments/environment';

const routes: Routes = [
  { path: '', loadChildren: './modules/main/main.module#MainModule' },
];

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    RouterModule.forRoot(routes),
    NavbarModule,
    FooterModule,
    CoreModule,
    LoggerModule.forRoot(environment.logging),
    NgxUiLoaderModule
  ],
  providers: [
    AuthService,
    UtilService,
    UserService,
    ReferralService
  ],
  bootstrap: [AppComponent]
})

export class AppModule {
}

Answer №1

The issue you are experiencing is due to the fact that your NGXLoggerHttpService relies on the HttpBackend class, which has not been imported into the providers section of your module.ts file. To resolve this error, make sure to import the HttpBackend into your providers.

Answer №2

Referencing this specific concern, the issue can be resolved by importing HttpClientModule and including it in the module's imports

import { HttpClientModule } from '@angular/common/http';
...
imports: [ ..., HttpClientModule, ...]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the method of finding the second lowest and second highest values within an array

Hey there fellow Stack users, Please excuse me if this question has already been asked or is too basic (I'm still new to Javascript). Recently, I've been working on some w3c js challenges: Create a JavaScript function that can identify the seco ...

In Angular Google Maps, here's a step-by-step guide on how to zoom in

I am currently utilizing agm/core to showcase the coordinates of a map. Here is the code snippet I am using: <agm-map [latitude]="10.3207886" [longitude]="123.90250049999997"> <agm-marker [latitude]="10.3207886 [longitude]="123.90250049999997 ...

How can I update the image source using Angular?

<div class="float-right"> <span class="language dashboard" data-toggle="dropdown"> <img class="current" src="us-flag.png" /> </span> <div class="dropdown dashboar ...

An investigation into the texturing and highlighting problem in Three.js

I am currently working on a project involving a cube with multiple textures, one for each face. Initially, I was able to change the color of the cube when hovering over it using a single texture. However, I now want to implement this functionality with a t ...

Refreshing Templates in Angular with ui.router

Initially, I apologize for the lengthy question, but it is necessary. Regrettably... I have multiple templates and routing logic stored in separate files. Strangely, the template I wish to load (depending on the selected region) does not initially load it ...

Blurry text issue observed on certain mobile devices with Next.js components

There continues to be an issue on my NextJS page where some text appears blurry on certain mobile devices, particularly iPhones. This problem is only present on two specific components - both of which are interactive cards that can be flipped to reveal the ...

Invoking a function within a loop

In order to complete this assignment with a pop art theme, I have chosen to incorporate pokeballs into the design. The task at hand involves using two for loops, one for the top row and one for the bottom row, while also creating a function. The main cha ...

Cannot use a 'string' type expression to index a 'Request<ParamsDictionary, any, any, Query>' type

Currently, my goal is to develop a middleware that can validate the input data in a request. export function validator(schema: Joi.ObjectSchema, key: string) { return function (req: Request, res: Response, next: NextFunction): void { try { Joi ...

The directionalLight Properties do not yield any visible results

I recently experimented with the parameters in this code snippet but did not see any visible changes. The values for directionalLight.shadowCameraVisible, directionalLight.shadowCameraLeft, directionalLight.shadowCameraRight, directionalLight.shadowCameraB ...

Guide on utilizing angularjs $q.all() method with a dynamically generated set of promises

I am currently facing an issue with using $q.all() to wait for multiple promises to be resolved. I have created an array of promises and passed it to the all() method, but it doesn't seem to be working as expected. The promises in the array are gener ...

Trouble with passing options to ES6 module imports

After coming across this Stackoverflow thread, I am attempting to pass options to ES6 imports. Initially, this code worked without any issues: export default (Param1:any, Param2:any) => { return class Foo { constructor() { cons ...

Issue with form submission

I'm experiencing an issue with a form on my website where users can share an email. The form is supposed to pop up and allow users to send an automated subject and message to a friend. However, when I try to submit the form, the browser displays a 404 ...

Is there a way to store the form data as a text file using jQuery or JavaScript and sending it to a PHP file?

I have created a basic html form with pre-filled information for demonstration purposes. Currently, when the form is submitted, it is saved to Google Docs successfully. However, I also want to save the form output to a text file on the server where the p ...

Using Vue to send information to Firebase

I could really use some assistance. Despite my best efforts over the past few days, and despite watching numerous tutorials and consulting various methods in Firebase documentation, I am still unable to make any progress. My current project involves build ...

Eliminate redundant items within an array, focusing on a single attribute in the objects

Recently, I was tackling a coding challenge involving identifying unique objects within an array. After researching and experimenting with various code snippets, I managed to find a solution that almost fits my requirements. Let's consider the follo ...

The function GetSomething() in sequelize.js is displaying inaccurate values when used in a hasOne relationship, but is showing the correct values in a BelongTo

I'm encountering an issue where trying to fetch a Fluxo through a relationship in my CanaisCadastro results in the GetFluxo() function returning the incorrect row. On the other hand, using the foreign key in a findOne query returns the expected value. ...

Issue with Jhipster4 when trying to generate an Angular 2 app

After utilizing jhipster4 to create my application, I noticed it consists of a client side and a server side. However, when running ./mvnw from the application's root directory, only the server is built, without the client. Here is the structure of my ...

Before each loop, a return value is encountered

I'm facing a challenge when attempting to sort names in two separate arrays. Once I retrieve the final result, it seems to return the values first before executing the forEach loop. const available = []; const taken = []; const names = d ...

The Angular Element's emitted number transforms into a string once it reaches the JavaScript event listener

Within my Angular Elements web component, I have defined and emitted events in the following way: @Input() groupId: number = -1; @Output('group_change') groupChange!: EventEmitter<number>; ... this.groupChange.emit(groupId); I integrated ...

Encountering duplicate entries within the dropdown menu

I have a dropdown menu that fetches values from a JSON file, but there are some repeated values in the JSON file. I want to ensure that these repeated values only appear once. Initially, I was able to filter out the duplicates successfully. However, after ...