storybook: ModuleNotFoundError @storybook/addon-docs NPM 7

Describe the bug Can't resolve '@storybook/addon-docs/blocks' in '/Users/me/myproject/path/to/stories'. I can’t import addon-docs from my stories, after I upgraded to storybook 6.2.1 (from 6.1.17). I have addon-essentials installed.

I suspect this has something to do with incompatibility issues with NPM 7 workspaces. I get this error in a subpackage from a worspace set-up.

A workaround is to install addon-docs explicitly instead of just addon-essentials. But afaik that’s should not be the case, since not even sb init installs it explicitly.

To Reproduce Install Storybook version 6.2.1 inside a subpackage of an NPM 7 workspaces and try importing something from addon-docs inside an MDX story.

Screenshots Screenshot 2021-04-01 at 10 04 08

Code snippets If applicable, add code samples to help explain your problem.

System

Environment Info:

  System:
    OS: macOS 11.2.3
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 15.8.0 - ~/.nvm/versions/node/v15.8.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.4/bin/yarn
    npm: 7.6.3 - ~/.nvm/versions/node/v15.8.0/bin/npm
  Browsers:
    Chrome: 89.0.4389.114
    Edge: 89.0.774.63
    Firefox: 86.0
    Safari: 14.0.3

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 16
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I fixed this exact same error by removing the following lines from storybook/addons.js: import ‘@storybook/addon-actions/manager’; import ‘@storybook/addon-knobs/manager’; import ‘@storybook/addon-links/manager’;

Please add @storybook/addon-docs as a project dependency