Hello,
I'm getting this error when trying to import EffectsModule in app.module.ts
No provider for Actions! ; Zone:
here is how import looks like: EffectsModule.forRoot([MyEffects])
Can anyone help?
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.
Most helpful comment
app.module.ts:-
Then ensure if you're using effects that you have