Search code examples
angularngrxngrx-storengrx-store-4.0

Error: No Provider for Store! in @ngrx 4.x


When migrating my project from @ngrx 2.x to 4.1.0, I encountered the error message

NullInjectorError: No provider for Store!

The store was imported as shown in the docs:

import { StoreModule as NgRxStoreModule } from '@ngrx/store';

@NgModule({
  imports: [
    NgRxStoreModule.forRoot(reducerMap, {
      initialState: initial
    }),
    StoreRouterConnectingModule,
    EffectsModule.forRoot(effects)
  ],
  providers: [AppActions]
})
export class StoreModule {}

Solution

  • Turned out that some of my services imported the store via

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

    Changing the imports to

    import { Store } from '@ngrx/store'
    

    fixed the problem.