1

In our application we are using Angular(version 10) and ngrx(version 7). My app was running fine till I changed the tsconfig. I changed the below property:

"module": "commonjs"

to

"module": "es2020" 

From then I started getting the below error:

Uncaught ReferenceError: Cannot access 'jobTreeReducers' before initialization

Following is the folder structure for the error raised module

enter image description here

The job-tree-store.module.ts is

import { NgModule } from "@angular/core";
import { StoreModule } from "@ngrx/store";
import { EffectsModule } from "@ngrx/effects";
import { CommonModule } from '@angular/common';
import { jobTreeReducers, JobTreeEffects } from "./index";

@NgModule({
    imports: [
        CommonModule,
        StoreModule.forFeature('jobTree', jobTreeReducers),
        EffectsModule.forFeature([JobTreeEffects]),
    ]

})
export class JobTreeStoreModule {}

I imported that and using in the App Module.

Please help me solve this issue.

Thanks...

Sai M.
  • 2,548
  • 4
  • 29
  • 46
  • 2
    This is typically a circular dependency problem. – Bergi Aug 13 '21 at 10:42
  • 1
    @Bergi, We put all the store stuff into a module and importing that into the app module. Can you please help how this circular dependency has occured? – Sai M. Aug 13 '21 at 10:54
  • 1
    Same, had this issue and looked for a circular dependency -> found and fixed it. Thanks @Bergi – Deitsch Nov 09 '21 at 19:12
  • Can you please give an example of what kind of circular dependency should I look for @Deitsch Thanks! – Mr. DMX Jan 20 '23 at 20:58
  • 1
    I can't recall 100% anymore, but 2 files were importing parts of each other – Deitsch Jan 20 '23 at 21:15

0 Answers0