Search code examples
angularangular8storybookangular-storybook

Angular 8 with Storybook 6


Getting the below error while installing and starting a storybook.

ERROR in /Users/username/angular-storybook/src/stories/Button.stories.ts
ERROR in /Users/username/angular-storybook/src/stories/Button.stories.ts(2,29):
TS2307: Cannot find module '@storybook/angular/types-6-0'.

ng version

Angular CLI: 8.3.29
Node: 12.16.2
OS: darwin x64
Angular: 8.2.14

Dev dependency

    "@compodoc/compodoc": "^1.1.11",
    "@storybook/addon-actions": "^6.0.12",
    "@storybook/addon-essentials": "^6.0.12",
    "@storybook/addon-links": "^6.0.12",
    "@storybook/angular": "^6.0.12"

Solution

  • As a workaround, I have updated the imports from Button, Header, Page{.stories}:

    From --->
    import { Story, Meta } from '@storybook/angular/types-6-0';
    
    To  ---->
    import { Story, Meta } from '@storybook/angular';
    

    This works fine. But not sure why the boilerplate code has the issue. :( This works fine with version 6.0.12.

    Updates: With newer version of the storybook(>6.2.*), Explicitly declare in typings.d.ts inside the .storybook directory. (mentioned by @Mr.7)

    declare module '@storybook/angular'