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

Anton Poznyakovskiy picture Anton Poznyakovskiy · Nov 6, 2017 · Viewed 13.6k times · Source

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 {}

Answer

Anton Poznyakovskiy picture Anton Poznyakovskiy · Nov 6, 2017

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.