Platform: EffectsModule breaks on RxJS6

Created on 2 Apr 2018  路  10Comments  路  Source: ngrx/platform

Hi,
after upgrading to the 6.0.0 beta.0 I am having issues with the effects module.

Even the simplest effects module with an empty array of effects still gives the following error when importing the EffectsModule:

..... misc imports

import { reducers } from './my-store';
let effects: Array<any> = [];

@NgModule({
  imports: [
    BrowserModule,
    RouterModule.forRoot(routes),
    StoreModule.forRoot(reducers),
    EffectsModule.forRoot(effects)
  ],
...

Notice the EffectsModule is called with no effects. If I remove the EffectsModule line everything works.
The error when including the EffectsModule is:

Error: StaticInjectorError(AppModule)[EffectsRootModule -> Store]: 
  StaticInjectorError(Platform: core)[EffectsRootModule -> Store]: 
    NullInjectorError: No provider for Store!

Dependencies:

Angular 6.0.0 RC.1
RxJS 6.0.0 RC.0
Ngrx/store, Ngrx/effects : 6.0.0-beta.0
Ngrx/core: 1.2.0 (now removed)
Typescript: 2.7.1 / 2.8.1

6.x Needs Reproduction Effects

Most helpful comment

v6.0.0-beta.1 of NgRx has been released with a fix for this bug.

All 10 comments

Ngrx/core: 1.2.0

Why do you need ngrx/core ? I think this package has been removed since ngrx v4.

@sandangel Good question lol... I'll remove it and see what happens :)

Update - same issue. I wasn't using ngrx/core, it was just in my package.json for some reason. Thanks for pointing out that I can remove it.

I have the same issue after upgrading to Ngrx 6.0.0-beta.0. However, it works if I run "ng serve --aot" instead of "ng serve". I found that workaround while searching previous related issues like #184

From what I understand, the Store module has to be loaded before loading other Ngrx modules, but for some reason the Store module is not found when running the app with the JIT compiler. With aot, the right module gets imported and the app runs without any problem in my case.

same problem, ng serve and ng build with aot work fine, but ng test which doesn't support aot causes

Error: StaticInjectorError(AppModule)[EffectsRootModule -> Store]: 
  StaticInjectorError(Platform: core)[EffectsRootModule -> Store]: 
    NullInjectorError: No provider for Store!

I think this is the first bug where it works correctly with AOT and incorrectly with JIT 馃え

I have created a simple project that reproduces the issue: https://github.com/MakesNine/testapp

Project works using "ng serve --aot" but doesn't work with "ng serve".

@MakesNine thanks!
I also have a repo demonstrating the same issue.

https://github.com/spock123/ngrx-effects-test

I am NOT using the CLI but using a custom webpack build.

Glad I'm not the only one with the issue, was going mad :) lol
Thanks guys! Appreciate it

v6.0.0-beta.1 of NgRx has been released with a fix for this bug.

When I am importing StoreModule in app module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
By only importing StoreModule in below line, erros is coming...
import { StoreModule } from '@ngrx/store'; 
import { AppComponent } from './app.component';

// import { reducer } from './reducers/Tutorial.reducer';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    StoreModule.forRoot({}) 
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Below error is coming, kindly help me to resolve this....

ERROR in node_modules/@ngrx/store/src/action_creator.d.ts(11,124): error TS2344: Type 'ParametersType<C>' does not satisfy the constraint 'any[]'.
  Type '{}' is not assignable to type 'any[]'.
    Type '{}' is not assignable to type 'any[]'.
      Property 'includes' is missing in type '{}'.
node_modules/@ngrx/store/src/models.d.ts(30,58): error TS2304: Cannot find name 'unknown'.
node_modules/@ngrx/store/src/models.d.ts(30,82): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,52): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,73): error TS2304: Cannot find name 'unknown'.

When I am importing StoreModule in app module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
By only importing StoreModule in below line, erros is coming...
import { StoreModule } from '@ngrx/store'; 
import { AppComponent } from './app.component';

// import { reducer } from './reducers/Tutorial.reducer';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    StoreModule.forRoot({}) 
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Below error is coming, kindly help me to resolve this....

ERROR in node_modules/@ngrx/store/src/action_creator.d.ts(11,124): error TS2344: Type 'ParametersType<C>' does not satisfy the constraint 'any[]'.
  Type '{}' is not assignable to type 'any[]'.
    Type '{}' is not assignable to type 'any[]'.
      Property 'includes' is missing in type '{}'.
node_modules/@ngrx/store/src/models.d.ts(30,58): error TS2304: Cannot find name 'unknown'.
node_modules/@ngrx/store/src/models.d.ts(30,82): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,52): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,73): error TS2304: Cannot find name 'unknown'.

StoreModule.forRoot([ ])

Was this page helpful?
0 / 5 - 0 ratings