Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing to run ng build for prod with ngrx effects

Tags:

angular

I'm using angular 5. The app runs with ng build and ng serve. However it fails with --prod flag for both. Following is the error:

ERROR in Error: Invalid provider for the NgModule 'ɵd in /Users/me/project/node_modules/@ngrx/effects/effects.d.ts' - only instances of Provider and Type are allowed, got: [?null?]

Can someone give some hints?

like image 365
TrongBang Avatar asked May 14 '18 00:05

TrongBang


1 Answers

It's ridiculous. This problem is because ng-cli doesn't work well with default import in ES6.

In my component.module.ts, I included component.effects.ts as below.

import {EffectsModule} from '@ngrx/effects';
import MyEffects from '@app/component/state/component.effects';

@NgModule({
    imports: [
        ...
        EffectsModule.forFeature([ MyEffects ])
    ],
    ...
})

export class QueryModule {}

The error is import MyEffects from. I changed it to import {MyEffects} from and in my component.effects.ts, I replaced default import with named import.

like image 64
TrongBang Avatar answered Oct 26 '22 02:10

TrongBang