Error: No provider for Store! when trying @ngrx/store with Angular 4.0

Anton Pegov picture Anton Pegov · May 30, 2017 · Viewed 18.2k times · Source

Problem: Error: No provider for Store!

I'm bootstraping store module in main.ts:

platformBrowserDynamic().bootstrapModule(AppModule,[
  provideStore({
    characters, 
    vehicles
  })
]);

And injecting in to vehicle.component.ts:

constructor(
    private _route: ActivatedRoute,
    private _router: Router,
    private _vehicleService: VehicleService,
    private _store: Store<any>
  ) {}

Full source code is here: GitHub, last version running on GitHub Pages

PS. Adding Store to providers leads to another error: Can't resolve all parameters for Store: (?, ?, ?).

Answer

Alf Moh picture Alf Moh · Nov 16, 2017

I had this error because, in my component auto-import imported Store from import { Store } from '@ngrx/store/src/store' instead of import { Store } from '@ngrx/store'; . Anyway, this was in Angular 5