Storybook 6 error: ngrx no provider for Store error - how to fix?

4.7k Views Asked by At

My Angular10 application is working fine when using ng serve / nx serve. The NGRX store and Feature stores are working as expected.

However, when I try and run a Storybook from any of my Libs in the project I get errors. Why is this? How do I fix this? I have not found a solution so far.

This is part of the error:

StaticInjectorError(Platform: core)[InjectionToken @ngrx/store Check if Action types are unique -> InjectionToken @ngrx/store Internal Runtime Checks]: 
    NullInjectorError: No provider for InjectionToken @ngrx/store Internal Runtime Checks!

Does anyone know a solution? Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

@TitusSutioFanpula solved this for me. The issue was that I needed to import the Ngrx Store & Effects modules even though the actual feature running in the story did not use Ngrx.

So to get it to run without errors I needed to import them like this:

export default {
  title: 'LayoutComponent',
  decorators: [
    withKnobs,
    moduleMetadata({
      imports: [
        LayoutModule,
        StoreModule.forRoot({}),
        EffectsModule.forRoot([]),
        HttpClientModule
      ]
    })
  ]
};

Does anyone have any good guides / resources on Angular Storybook dev? (wish there was better documentation for Angular Storybook, this was supposed to speed my dev process but I am finding it more time consuming than ever)