Open Closed

NullInjectorError: No provider for InjectionToken CORE_OPTIONS! #5539


User avatar
0
enes.alper created
  • ABP Framework version: 7.2.2

  • UI Type: Angular

    • Database System: EF Core (PostgreSQL
    • Auth Server Separated (for Angular): No
  • Exception message and full stack trace: ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(TariffModule)[LocalizationService -> LocalizationService -> LocalizationService -> LocalizationService -> SessionStateService -> ConfigStateService -> AbpApplicationConfigurationService -> RestService -> InjectionToken CORE_OPTIONS -> InjectionToken CORE_OPTIONS -> InjectionToken CORE_OPTIONS]: NullInjectorError: No provider for InjectionToken CORE_OPTIONS! NullInjectorError: R3InjectorError(TariffModule)[LocalizationService -> LocalizationService -> LocalizationService -> LocalizationService -> SessionStateService -> ConfigStateService -> AbpApplicationConfigurationService -> RestService -> InjectionToken CORE_OPTIONS -> InjectionToken CORE_OPTIONS -> InjectionToken CORE_OPTIONS]: NullInjectorError: No provider for InjectionToken CORE_OPTIONS! at NullInjector.get (core.mjs:7493:27) at R3Injector.get (core.mjs:7914:33) at R3Injector.get (core.mjs:7914:33) at R3Injector.get (core.mjs:7914:33) at injectInjectorOnly (core.mjs:618:33) at Module.ɵɵinject (core.mjs:622:60) at Object.RestService_Factory [as factory] (abp-ng.core.mjs:58:110) at R3Injector.hydrate (core.mjs:8015:35) at R3Injector.get (core.mjs:7903:33) at injectInjectorOnly (core.mjs:618:33) at resolvePromise (zone.js:1214:31) at resolvePromise (zone.js:1168:17) at zone.js:1281:17 at _ZoneDelegate.invokeTask (zone.js:409:31) at core.mjs:23896:55 at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:23896:36) at _ZoneDelegate.invokeTask (zone.js:408:60) at Object.onInvokeTask (core.mjs:24197:33) at _ZoneDelegate.invokeTask (zone.js:408:60) at Zone.runTask (zone.js:178:47)

  • Steps to reproduce the issue: We have a module library (name is Generals module) and this module have many components. One of these components is company component. Also company component have a child component and name is create-company component. So company and create-company have parent-child relationship. Also we have another module in another project and name is Sales module. We want to export the create-company component (child) and use it in the Sales module. Because both modules have create-company field in their page and we want to use same component in both modules for singularity. But when serving the sales module, we get the error that I typing the above. Also we tried the way in this link but it didn't resolve our problem (https://support.abp.io/QA/Questions/773/NullInjectorError-when-access-to-Permission-features). Both modules dependencies are same version.

We bind two modules and tried this way. In Generals module we run ng serve generals --watch, then we replace tsconfig.json file in the Sales module like in the screenshot and we specified the dist path of the generals module.

Please let me know how to check or fix it

Thanks support team.


4 Answer(s)
  • User Avatar
    0
    mahmut.gundogdu created

    It seems ABP core modules are not provided. Could you check your imports of TariffModule?

    It is not related, but you can use the direct TS version of the module. You don't have to use a compiled version. Just add the index.ts path; it should work without compiling specifically. CORE_OPTIONS defined in CoreModule.forRoot()

  • User Avatar
    0
    enes.alper created

    Firstly, thank you for your answer. In TariffModule we import the core module . So we think that core modules are provided in our tariff module. As you can see in the screenshot, the error message say that, there is a circular dependecy for LocalizationService. I told you before that we have 2 projects (Generals and Sales) Our create-company component (in Generals) use localization service in it. And we exported this component. Then we are looking at another project (the Sales) , we want to import the create-company component in this project. We added the related module to the TariffModule (in Sales) and we faced this problem. Also, Tariff component use the localization service. So, we think that, localization services in the create-company component and tariff component may cause circular DI. Then, we removed the localization service in the create-company component and the error message changed like this. . This time, company service may cause circular DI. Because, CompanyService in the create-company component inject the RestService and also TariffService in the tariff component inject the RestService. This time we thought that's why circular DI happend. Maybe, the first error message(No provider for InjectionToken CORE_OPTIONS) cause this circular DI. I'm not sure about this.

    I'm waiting for your reply. Thank you.

  • User Avatar
    0
    enes.alper created

    Hi team, Is there any update for this ticket? Best wishes

  • User Avatar
    0
    mahmut.gundogdu created

    CORE_OPTIONS token provided in CoreModule.forRoot(). So you must import CoreModule.forRoot(), ThemeSharedModule.forRoot(), in your module. othervise ABp spesific codes does not work.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11