Search code examples
angulartypescriptstorybookangular-storybook

Storybook Cannot find module '@storybook/angular'


I am trying to setup Storybook for Angular 8, however when running npm run storybook I am getting the following error:

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

ERROR in /home/user/dev/storybook/src/stories/Header.stories.ts
ERROR in /home/user/dev/storybook/src/stories/Header.stories.ts(1,32):
TS2307: Cannot find module '@storybook/angular'.

ERROR in /home/user/dev/storybook/src/stories/Header.stories.ts
ERROR in /home/user/dev/storybook/src/stories/Header.stories.ts(4,29):
TS2307: Cannot find module '@storybook/angular/types-6-0'.

ERROR in /home/user/dev/storybook/src/stories/Page.stories.ts
ERROR in /home/user/dev/storybook/src/stories/Page.stories.ts(1,45):
TS2307: Cannot find module '@storybook/angular'.

However, @storybook/angular is on package.json and it is installed, as well as the file itself does not prompt any errors when visualizing with vscode. I have tried to use all solutions from google, such as:

  • Importing everything from @storybook/angular and not using @storybook/angular/types-6-0
  • Adding @storybook/angular/types-6-0 to .storybook/typings.d.ts
  • Adding ../src/setupJest.ts to the exclude array in .storybook/tsconfig.json
  • Adding "enableIvy": false to tsconfig.json under angularCompilerOptions

My package.json

What am I doing wrong?


Solution

  • just add the following line in "typings.d.ts" that can be found inside the .storybook directory

    declare module '@storybook/angular/demo'