Platform: @nrgx/effects issue

Created on 20 Jul 2017  路  6Comments  路  Source: ngrx/platform

Hello,

I'm getting this error when trying to import EffectsModule in app.module.ts

No provider for Actions! ; Zone: ; Task: Promise.then ; Value: Error: No provider for Actions!

here is how import looks like: EffectsModule.forRoot([MyEffects])

Can anyone help?

Most helpful comment

app.module.ts:-

import { EffectsModule } from '@ngrx/effects';
import { YourOptionalModule } from './some/module';

...
@NgModule({
    imports: [
        EffectsModule.forRoot([]),
        YourOptionalModule 
    ]

Then ensure if you're using effects that you have

import { YourCustomEffectHere} from './some/effects';

@NgModule({
    imports: [
        // For the actions
        EffectsModule.forFeature([
          YourCustomEffectHere
        ])
    ],
...
export class YourOptionalModule { }

All 6 comments

do you put your actions in the providers in @NgModule?

I tried put Actions to providers like

import { EffectsModule, Actions } from '@ngrx/effects';

and then

@NgModule({
...
providers: [
 Actions,
]
...
})

It didn't work.

app.module.ts:-

import { EffectsModule } from '@ngrx/effects';
import { YourOptionalModule } from './some/module';

...
@NgModule({
    imports: [
        EffectsModule.forRoot([]),
        YourOptionalModule 
    ]

Then ensure if you're using effects that you have

import { YourCustomEffectHere} from './some/effects';

@NgModule({
    imports: [
        // For the actions
        EffectsModule.forFeature([
          YourCustomEffectHere
        ])
    ],
...
export class YourOptionalModule { }

I meant your own action class not Actions from '@ngrx/effects'

@Cosmocat We had the exact same error in our project after upgrading/refactoring it for NGRX4. In our case it was a faulty import from ngrx/effects. This is the commit that fixed it for us:

- import { Actions, Effect } from '@ngrx/Effects';
+ import { Actions, Effect } from '@ngrx/effects';

So you should probably look for some typo somewhere.

Thx, I got it working using @adammartin1981 approach.

Was this page helpful?
0 / 5 - 0 ratings