ohadinho
ohadinho

Reputation: 7144

Angular 4, ngrx\store Plunker - TypeError: store_1.StoreModule.provideStore is not a function

I'm trying to create an Angular 4 plunker which includes ngrx\store latest version: https://embed.plnkr.co/cr4rCJ0hRVMwuLzKe4mg/

In order to use ngrx\store i've added this line in config.js file:

'@ngrx/store': 'https://npmcdn.com/@ngrx/[email protected]',

For some reason i'm getting this error:

(SystemJS) TypeError: store_1.StoreModule.provideStore is not a function

Can someone assist?

Upvotes: 2

Views: 1243

Answers (2)

sushil kumar
sushil kumar

Reputation: 31

You should change 'provideStore' to 'forRoot' in latest version of Angular like Angular 6. It worked for me.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule} from '@angular/forms';
import { UsersServiceService } from './users/users-service.service';
import { PDFGenerationService } from './pdf-generation-demo/pdf-generation.service';
import { AppRoutingModule, routingComponents } from './app-routing.module';
// Import ng-circle-progress
import { NgCircleProgressModule } from 'ng-circle-progress';
import { mainStoreReducer } from './state/reducers/reducer';
import { StoreModule } from '@ngrx/store';


@NgModule({
  declarations: [
    AppComponent,
    routingComponents
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    AppRoutingModule,
    NgCircleProgressModule.forRoot({
      // set defaults here
      radius: 100,
      outerStrokeWidth: 16,
      innerStrokeWidth: 8,
      outerStrokeColor: "#78C000",
      innerStrokeColor: "#C7E596",
      animationDuration: 300
    }),
    StoreModule.forRoot({ mainStoreReducer })
  ],
  exports: [   ],
  providers: [UsersServiceService, PDFGenerationService],
  bootstrap: [AppComponent]
})

export class AppModule { }

Upvotes: 0

Anastasis
Anastasis

Reputation: 729

In the latest version of Ngrx the provideStore changed to forRoot.

Also you could have a look at the migration guide here https://github.com/ngrx/platform/blob/master/MIGRATION.md

Upvotes: 4

Related Questions