Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook React dependency issue with NPM 7 #15725

Closed
Varedis opened this issue Jul 30, 2021 · 4 comments
Closed

Storybook React dependency issue with NPM 7 #15725

Varedis opened this issue Jul 30, 2021 · 4 comments

Comments

@Varedis
Copy link

Varedis commented Jul 30, 2021

Describe the bug
Incorrect module resolution when React is installed as a dependency.

When installing storybook if react and react-dom are dependencies it causes issues with modules like addon-docs not being installed correctly from addon-essentials.

image

For whatever reason they get nested inside addon-essentails and not installed at the top level.

Removing the node_modules and deleting the package-lock.json and installing again produces the same issue.

Once you delete react and react-dom from the dependencies and reinstall the packages, addon-docs gets correctly installed.

You can also use --legacy-peer-deps which causes correct resolutions of all packages.

Seemingly having react as a dependency and a peer dependency somehow causes unintended issues with other packages even though the versions meet all peer dependency requirements

I have created a simple repo below that replicates the issue

To Reproduce

Reproduction repo can be found here: https://github.com/Varedis/storybook-peer-issue

System

Environment Info:

  System:
    OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz
  Binaries:
    Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
    npm: 7.20.3 - ~/.nvm/versions/node/v12.16.3/bin/npm
  npmPackages:
    @storybook/addon-actions: ^6.3.6 => 6.3.6 
    @storybook/addon-essentials: ^6.3.6 => 6.3.6 
    @storybook/addon-links: ^6.3.6 => 6.3.6 
    @storybook/node-logger: ^6.3.6 => 6.3.6 
    @storybook/preset-create-react-app: ^3.2.0 => 3.2.0 
    @storybook/react: ^6.3.6 => 6.3.6 

Additional Info

No errors or peer warnings on either install, just a broken package tree.

@Varedis Varedis changed the title Storybook dependency Storybook React dependency issue with NPM 7 Jul 30, 2021
@shilman
Copy link
Member

shilman commented Aug 2, 2021

Closing this as duplicate to #14119. Please let me know if you think it's a separate issue! 🙏

@Varedis
Copy link
Author

Varedis commented Aug 2, 2021

Hi @shilman

Whilst related, I believe the issue is separate for the following reasons:

  1. Relying solely on storybook peer dependences for react and not including them as part of the app works. So it doesn't appear to be the new way npm handles peers.
  2. No errors or warnings given when installing about peers or incorrect installs.
  3. Seems very specific to addon-essentials but only when react is installed as a direct dependency.

@shilman shilman reopened this Aug 2, 2021
@shilman
Copy link
Member

shilman commented Aug 2, 2021

@Varedis thanks for the clarification, reopening!

@ndelangen
Copy link
Member

This is fixed in storybook 7.0 beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants