Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in using ngx-logger in an angular library (buildable) #298

Open
hmendezm opened this issue Mar 2, 2022 · 6 comments
Open

Issue in using ngx-logger in an angular library (buildable) #298

hmendezm opened this issue Mar 2, 2022 · 6 comments

Comments

@hmendezm
Copy link

hmendezm commented Mar 2, 2022

Hi guys,
I am trying to use ngx-logger in my buildable library but I got the error below
core.mjs:6500 ERROR NullInjectorError: R3InjectorError(AppModule)[TestService -> TestService -> TestService -> NGXLogger]:
NullInjectorError: No provider for NGXLogger!

app/module

@NgModule({
....
  imports: [
    BrowserModule,
    HttpClientModule,
    LoggerModule.forRoot({
      level: NgxLoggerLevel.DEBUG,
      timestampFormat: 'HH:mm:ss.SSS',
      serverLogLevel: NgxLoggerLevel.ERROR,
      disableConsoleLogging: false
    })]
})
export class AppModule { }

library module

@NgModule({
  imports: [CommonModule, LoggerModule.forChild()]
})
export class ReusableModule {}
@bmtheo
Copy link
Collaborator

bmtheo commented Mar 2, 2022

Do you build the library by itself or with the app ?

@hmendezm
Copy link
Author

hmendezm commented Mar 2, 2022

Hi bmtheo,

I build the library with the app

@bmtheo
Copy link
Collaborator

bmtheo commented Mar 3, 2022

Ok I tried in the project with the same setup (app.module with LoggerModule.forRoot and another module with LoggerModule.forChild) and it works fine

We probably have something different, can you provide a reproduction repo so that I can look into that ?

@hmendezm
Copy link
Author

hmendezm commented Mar 4, 2022

Ok. I will create a simple app and reproduce the problem

@hmendezm
Copy link
Author

hmendezm commented Mar 4, 2022

I could not reproduce in a new project. it looks like is a real project that has config problems and I do not know where.
this is the full error that I get

By the way, I am working on MFE and the services are a shared library. I use providedIn: 'platform', so I have one instance of the service when there is more than one app loaded.

bootstrap.ts:13 NullInjectorError: R3InjectorError(AppModule)[EffectsRootModule -> InjectionToken @ngrx/effects Root Effects -> AuthenticationEffects -> AuthenticationService -> StateService -> FormService -> FormService -> FormService -> LoggerService -> NGXLogger]: 
  NullInjectorError: No provider for NGXLogger!
    at NullInjector.get (core.mjs:11135:27)
    at R3Injector.get (core.mjs:11302:33)
    at injectInjectorOnly (core.mjs:4786:33)
    at Module.ɵɵinject (core.mjs:4790:12)
    at Object.LoggerService_Factory [as factory] (logger.service.ts:8:27)
    at R3Injector.hydrate (core.mjs:11472:35)
    at R3Injector.get (core.mjs:11291:33)
    at injectInjectorOnly (core.mjs:4786:33)
    at Module.ɵɵinject (core.mjs:4790:12)
    at Object.FormService_Factory [as factory] (form.service.ts:94:25)

@egandro
Copy link

egandro commented Jun 29, 2023

@hmendezm works for me with MEF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants