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.

Why does @storybook/addon-docs have babel-loader as a peer dependency?

See original GitHub issue

Describe the bug When I install packages, I get this warning:

warning "@storybook/addon-docs@6.1.1" has unmet peer dependency "babel-loader@^8.0.0".

Why should I add babel-loader as a dependency when it already comes with Storybook? Doing so is kind of dangerous because it runs the risk of having mismatched versions in the dependency tree. It seems like this peer dependency is not needed.

To Reproduce Steps to reproduce the behavior:

  1. Install @storybook/addon-docs with yarn.

Expected behavior No warnings.

System

Environment Info:

  System:
    OS: Windows 10 10.0.19042
    CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  Binaries:
    Node: 14.15.0 - C:\Program Files\Node.js\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.8 - C:\Program Files\Node.js\npm.CMD
  Browsers:
    Chrome: 86.0.4240.198
    Edge: Spartan (44.19041.423.0), Chromium (86.0.622.69)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:33 (13 by maintainers)

github_iconTop GitHub Comments

30reactions
Duncan-Alexander-Couttscommented, Feb 22, 2021

Still seeing this issue too, all with latest versions

29reactions
prymitivecommented, Nov 20, 2020

FYI react-scripts package expects a specific version of babel-loader and will fail to run if installed version is not what it wants. It seems that storybook/core can pull in a newer version (as the dependency there is more relaxed) which breaks CRA:

> react-scripts build


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.1.0"

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/lukasz/Work/karma/ui/node_modules/babel-loader (version: 8.2.1)

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/lukasz/Work/karma/ui/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 ls babel-loader
ui@0.0.1 /Users/lukasz/Work/karma/ui
├─┬ @storybook/react@6.1.1
│ └─┬ @storybook/core@6.1.1
│   └── babel-loader@8.2.1
└─┬ react-scripts@3.4.4
  └── babel-loader@8.1.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with npm install - Could not resolve dependency. Is ...
I tried to launch --legacy-peer-deps but this creates a package-lock.json with "lockfileVersion" setted to 2. I want to create a regular ...
Read more >
@storybook/addon-docs versions and peer dependencies
Online Peer dependency version tool to search for compatible versions of related NPM packages.
Read more >
@storybook/addon-docs - npm
yarn add -D @storybook/addon-docs. Docs has peer dependencies on react . If you want to write stories in MDX, you may need to...
Read more >
styled-components@5.3.5" has unmet peer dependency ...
0". warning " > @material-ui/core@4.12.4" has incorrect peer dependency "react-dom@^16.8.0 || ^17.0 ...
Read more >
Storybook with ReactJS TypeScript | by Anny Caroline - Medium
For documentation, Storybook addon docs can be used. ... which are Storybook peer dependencies (link to storybook doc).
Read more >

github_iconTop Related Medium Post

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