storybook: Storybook/react incompatible with older versions of react
Describe the bug We tried to setup a new storybook with an older version of React and see a number of issues from npm. Our particular project is constrained to react 16.4.1 for a variety of reasons; upgrading it is not an option. React will be provided as a webpack external, hence loaded outside of webpack bundle (oh the joys of working with legacy code).
You’d think this would work because @storybook/react has an extremely broad peer dependency, but that’s not what we’re seeing.
To Reproduce Steps to reproduce the behavior:
npm install --save-dev react@16.4.1 react-dom@16.4.1npm install --save-dev @storybook/reactnpm install --save-dev babel-loader @babel/corenpm ls react
Expected behavior npm lists the versions of react; all react dependencies and peer dependencies are satisfied.
Screenshots
% npm ls react
my-react-components@2.15.0 /Users/zebraflesh/projects/my-react-components
├─┬ @storybook/react@5.3.19
│ ├─┬ @storybook/addons@5.3.19
│ │ └─┬ @storybook/api@5.3.19
│ │ └── react@16.13.1
│ └─┬ @storybook/core@5.3.19
│ └─┬ @storybook/ui@5.3.19
│ ├─┬ @storybook/components@5.3.19
│ │ └── UNMET PEER DEPENDENCY react@16.13.1
│ └── UNMET PEER DEPENDENCY react@16.13.1
└── react@16.4.1
npm ERR! peer dep missing: react@^16.6.0, required by react-helmet-async@1.0.6
npm ERR! peer dep missing: react@^16.8.0, required by react-focus-lock@2.4.0
npm ERR! peer dep missing: react@^16.6.0, required by react-helmet-async@1.0.6
npm ERR! peer dep missing: react@^16.6.0, required by react-popper-tooltip@2.11.1
Code snippets N/A
System: System: OS: macOS 10.15.5 CPU: (8) x64 Intel® Core™ i7-6700K CPU @ 4.00GHz Binaries: Node: 12.18.1 - ~/.nvs/node/12.18.1/x64/bin/node npm: 6.14.5 - ~/.nvs/node/12.18.1/x64/bin/npm Browsers: Chrome: 83.0.4103.116 Edge: 83.0.478.54 Firefox: 75.0 Safari: 13.1.1 npmPackages: @storybook/react: ^5.3.17 => 5.3.19
Additional context A few things here are surprising:
- Various utilities that have strict react version requirements are pulled in (react-helmet-async, etc.), but whatever storybook packages are pulling them in are not supplying the necessary version.
@storybook/componentsreporting an unmet peer dependency at all – the parent@storybook/uipackage it has a direct dependency on react
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 17 (5 by maintainers)
This is still an issue, even with react-scripts 3.4.3. That depends on webpack 4.42.0, where @storybook/core (for @storybook/react 6.0.21) requires webpack 4.43.0. Short of setting
SKIP_PREFLIGHT_CHECK=true, I haven’t found any way to work around this.I’m not sure since that example doesn’t actually run from 5.13.9 tag. I see the following output (and get similar output running from the head of the
nextbranch):edit: That example shows similar issues to what I reported above:
@gaetanmaisse any chance you can look at this? seems vaguely related to the yarn2 stuff you’ve been up to, with stricter dep checking
Is there a way to force storybook to use a specific react version ? I am using resolutions in my package.json but that doesn’t work. I was thinking maybe I could mention that in the webconfig of the storybook.
FYI: I am using sb@5.3.21
Hi everyone! Seems like there hasn’t been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don’t have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Also experiencing this issue with blank
create-react-apprepo runningnpx sb initThe issue lives here: https://github.com/storybookjs/storybook/blob/34962f75be2832e0b3c39becade3f994fdf7702e/lib/cli/src/helpers.ts#L145-L151
This checks the package.json dependencies but doesn’t check the dependency tree for static versions. I’m not sure
babel-loadershould be added directly to the dependencies at all. Would removing the functionality altogether cause any issues elsewhere?Edit: Can confirm that removing this from my dev dependencies, and editing the lockfile to use React’s version for
^8.0.6fixed this issue.OLD yarn.lock instance
NEW yarn.lock instance
I have an almost identical issue today. I have run
npx sb initin my existing create react app repo and it has added"babel-loader": "^8.2.1",to mypackage.jsonfile and CRA is spitting out the above error but the version ofbabel-loaderit requires is8.1.0.This is apparently working for me in 6.0. What I did: