Angular standalone reporting circular dependencies where there are none, and with no...

Discussão em 'Angular' iniciado por peterc, Agosto 14, 2025.

  1. peterc

    peterc Guest

    I have been converting my Ionic Angular v20.1.4 application over to standalone, and I have had a few Circular dependency errors popup where there were none before.

    A couple of others I found a work around (thought I am dead sure there were no circular dependencies), but this one here is perplexing me, and I have no idea how to diagnose why this is happening.

    My ng/rx is setup using the old modules, as I cannot get the new provide methods to work for effect in classes (which is what I have), so I have in app.config.ts

    importProvidersFrom(
    StoreModule.forRoot({}),
    EffectsModule.forRoot([]),
    StoreModule.forFeature(Constants.vals.featureNames.appState, APP_REDUCER_TOKEN),


    All this was working fine, but adding back one of my service dependencies (see below) has caused the following..

    RuntimeError: NG0200: Circular dependency detected for `StoreFeatureModule`. Find more at https://angular.dev/errors/NG0200
    at createRuntimeError (root_effect_scheduler.mjs:895:19)
    at cyclicDependencyError (root_effect_scheduler.mjs:816:12)
    at R3Injector.hydrate (root_effect_scheduler.mjs:2147:23)
    at R3Injector.get (root_effect_scheduler.mjs:2007:33)
    at R3Injector.retrieve (root_effect_scheduler.mjs:1903:25)
    at injectInjectorOnly (root_effect_scheduler.mjs:1020:39)
    at ɵɵinject (root_effect_scheduler.mjs:1032:60)
    at useValue (root_effect_scheduler.mjs:1755:73)
    at R3Injector.resolveInjectorInitializers (root_effect_scheduler.mjs:2073:17)
    at core.mjs:906:31


    I have tracked it down (with no help from the actual error) to a root service that injects a Cordova Network plugin.

    So I have the global service

    import { Network } from '@awesome-cordova-plugins/network/ngx';

    @Injectable({
    providedIn: 'root',
    })
    export class NetworkService

    constructor(
    private network: Network, <-- remove this and the circular dependency goes away


    Looking on github, from what I can see the Network makes no use of ng/rx, as I expected it didn't.

    I do not use this Network anywhere else, I have it encapsulated in my own service, as sown above.

    My question is, how on earth can I track down WHY this causes a circular dependency to something completely unrelated, which was not there before going to standalone?

    I have look through the call stack, and it is quite hard to follow the logic.

    Any advice on how to diagnose this would be greatly appreciated.

    [UPDATE]

    Putting break points in again, I found an error that was not logged to the console...

    [​IMG]

    So I forgot to add the Network back to the providers in `app.config.ts' providers. After I did this, the error has gone.

    So, really the error messages is misleading

    Continue reading...

Compartilhe esta Página