question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

Storybook/react incompatible with older versions of react

See original GitHub issue

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:

  1. npm install --save-dev react@16.4.1 react-dom@16.4.1
  2. npm install --save-dev @storybook/react
  3. npm install --save-dev babel-loader @babel/core
  4. npm 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:

  1. 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.
  2. @storybook/components reporting an unmet peer dependency at all โ€“ the parent @storybook/ui package it has a direct dependency on react

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
TrueWillcommented, Sep 22, 2020

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.

3reactions
ZebraFleshcommented, Jun 23, 2020

Is this just some package dependency issue that needs to be fixed?

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 next branch):

cra-react15 % npm start

> cra-react15@5.3.19 start /Users/zebraflesh/git/storybook/examples/cra-react15
> react-scripts start


There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-loader": "8.0.5"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:

  /Users/zebraflesh/git/storybook/examples/cra-react15/node_modules/babel-loader (version: 8.0.6) 

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /Users/zebraflesh/git/storybook/examples/cra-react15/node_modules/babel-loader is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-loader in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-loader.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cra-react15@5.3.19 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cra-react15@5.3.19 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zebraflesh/.npm/_logs/2020-06-23T15_24_40_980Z-debug.log

edit: That example shows similar issues to what I reported above:

cra-react15 % npm ls react
cra-react15@5.3.19 /Users/zebraflesh/git/storybook/examples/cra-react15
โ”œโ”€โ”ฌ @storybook/addon-actions@5.3.19
โ”‚ โ”œโ”€โ”ฌ @storybook/api@5.3.19
โ”‚ โ”‚ โ””โ”€โ”€ react@16.13.1 
โ”‚ โ”œโ”€โ”ฌ @storybook/components@5.3.19
โ”‚ โ”‚ โ””โ”€โ”€ UNMET PEER DEPENDENCY react@16.13.1 
โ”‚ โ””โ”€โ”€ UNMET PEER DEPENDENCY react@16.13.1 
โ”œโ”€โ”ฌ @storybook/react@5.3.19
โ”‚ โ””โ”€โ”ฌ @storybook/core@5.3.19
โ”‚   โ””โ”€โ”ฌ @storybook/ui@5.3.19
โ”‚     โ””โ”€โ”€ UNMET PEER DEPENDENCY react@16.13.1 
โ””โ”€โ”€ react@15.6.2 

npm ERR! peer dep missing: react@^16.8.4, required by react-inspector@4.0.1
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
npm ERR! peer dep missing: react@>=16.3.0, required by @emotion/core@10.0.28
npm ERR! peer dep missing: react@>=16.3.0, required by emotion-theming@10.0.27
npm ERR! peer dep missing: react@^16.6.0, required by react-helmet-async@1.0.6
Read more comments on GitHub >

github_iconTop Results From Across the Web

Conflicting peer dependency react@17.0.2 when installing ...
Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/ย ...
Read more >
Cannot start React App after installing Storybook? Here's how ...
Manually installing incompatible versions is known to cause hard-to-debug issues.
Read more >
@storybook/react - npm
Storybook for React: Develop React Component in isolation with Hot Reloading.. Latest version: 6.5.15, last published: 5 days ago.
Read more >
@storybook/react | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
Introducing the New React DevTools
We are excited to announce a new release of the React Developer ... For older versions of React DOM (v0.14 or earlier) you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found