Describe the bug
When I install packages, I get this warning:
warning "@storybook/[email protected]" 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:
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)
Addon docs uses babel-loader AFAIK. So it should either be a dependency or a peer dependency. We might be able to loosen up the version specifier? Or do you have another proposal?
Given that any user of this addon will obviously have Storybook installed, they'll already have babel-loader:
$ yarn why babel-loader
yarn why v1.22.5
[1/4] Why do we have the module "babel-loader"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "[email protected]"
info Reasons this module exists
- "_project_#@storybook#core" depends on it
- Hoisted from "_project_#@storybook#core#babel-loader"
info Disk size without dependencies: "72KB"
info Disk size with unique dependencies: "580KB"
info Disk size with transitive dependencies: "4.45MB"
info Number of shared dependencies: 26
Done in 2.24s.
I'm not sure what's gained by the peer dependency. Keeping my babel-loader dependency in sync with whatever is being shipped with Storybook seems like unnecessary and time-consuming maintenance. Isn't it better to avoid the potential of version mismatches in the tree of dependencies?
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
[email protected] /Users/lukasz/Work/karma/ui
โโโฌ @storybook/[email protected]
โ โโโฌ @storybook/[email protected]
โ โโโ [email protected]
โโโฌ [email protected]
โโโ [email protected]
I'm getting the same error with react-scripts
as the previous comment.
If storybook is using create-react-app as a preset then wouldn't it make sense it should use the same babel-loader version that CRA uses?
Using a different version will always lead to the above error.
@cseas Yes, see #4764. @mrmckeb @tooppaaa can one of you please take care of this? it seems to be generating a lot of problems for people... ๐
I see that a similar problem applies to webpack, the difference is that webpack is only peer dependency so you end up with a warning rather than a build failure:
โโโฌ @storybook/[email protected]
โ โโโฌ @storybook/[email protected]
โ โ โโโ [email protected]
โ โโโ UNMET PEER DEPENDENCY [email protected]
โโโฌ [email protected]
โโโ [email protected]
I noticed that https://github.com/storybookjs/storybook/issues/4764 has been closed. Not sure if this was supposed to solve this issue?
I'm on Storybook v6.1.5 and am still seeing this issue.
@elie222 meaning you installed a fresh copy of storybook on a CRA with 6.1.5 and you're seeing the issue?
Not a fresh copy.
Using react-scripts 4.0.1 and Storybook 6.1.5 but upgrading an existing project:
https://github.com/FrontWorkDotDev/react-typescript-storybook-starter
@elie222 The fix here was NOT to install babel stuff at all if we're installing into a CRA app and to directly use the CRA setup instead. So it only applies to new storybook installs generated by the CLI. FWIW I'm not confident about the fix, but this issue seemed like it was breaking a bunch of people and it is worth a try.
It doesn't seem like there's a good solution for existing apps, other than perhaps to delete the dependencies by hand and reinstall. Can you try that?
Still no luck.
The output we're getting when running yarn start
is below. Basically started from a blank CRA app and still got the error. yarn storybook
works fine for us. Leaving as is for now as we don't actually need the CRA part for now but looks like this issue is still open.
yarn run v1.22.5
$ 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.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/Elie/Documents/Projects/FrontWork/storybook-repos/react-typescript-storybook-starter/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/Elie/Documents/Projects/FrontWork/storybook-repos/react-typescript-storybook-starter/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!
I've experienced just the same issue with a fresh install of Storybook in a Create-React-App.
In order to continue I've temporary added the following line in package.json
which allowed yarn to resolve babel-loader 8.1.0:
"resolutions": {
"babel-loader": "8.1.0"
},
This doesn't solve it for NPM yet.
Most helpful comment
@cseas Yes, see #4764. @mrmckeb @tooppaaa can one of you please take care of this? it seems to be generating a lot of problems for people... ๐