0

In my app.module.ts file I set up a store with:

imports: [
  StoreModule.forRoot(
    { soundtrackState: soundtrackReducer }
  ),
  EffectsModule.forRoot(
    [
      // SoundtrackEffects TODO add some effects
    ]
  ),
  StoreDevtoolsModule.instrument({ maxAge: 15, logOnly: environment.production }),    
  CoreModule,

Now, if I move this code out and into the core.module.ts file then I get the nullinjectorerror no provider for store error.

Stephane
  • 11,836
  • 25
  • 112
  • 175

2 Answers2

0

for any other module that root you need to use forFeature and I guess app.module' store should be initialized with code you wrote.

@NgModule({
  declarations: [

  ],
  imports: [
    EffectsModule.forFeature(groupModuleEffects),
    StoreModule.forFeature(GROUPS_FEATURE_NAME, groupModuleReducers),
    StoreDevtoolsModule.instrument({ maxAge: 25, logOnly: environment.production }),
    SharedModule
  ],
  providers: []
})
export class GroupsModule {}

Eric Aska
  • 611
  • 5
  • 14
  • I already tried the `forFeature` as in `StoreModule.forFeature('soundtrackFeature', { soundtrackState: soundtrackReducer }),` in another module. But it gives a `Cannot instantiate cyclic dependency! SoundtrackStore` error. – Stephane Jul 22 '20 at 07:49
  • @Stephane Seems this cyclic error is not releated to ngrx. https://stackoverflow.com/questions/57206026/angular-8-cannot-instantiate-cyclic-dependency-activatedroute. forFeature should be the way to go as it's said in documentation – Eric Aska Jul 22 '20 at 09:06
0

Some of your services may imported the store via

import { Store } from '@ngrx/store/src/store'

or

import { Store } from '@ngrx/store/store'

Make sure the imports are imported from,

import { Store } from '@ngrx/store'

If everything fine, there may be the problem with store definition. Please share your code of app.module.ts and core.module.ts with stackblitz or other way. So we can resolve the problem.