Yarn Build - Babel-loader issues with Storybook Yarn Build - Babel-loader issues with Storybook reactjs reactjs

Yarn Build - Babel-loader issues with Storybook


It is a known issue.

If you are using yarn, you can easily get around it using resolutions.Add the following to your package.json to allow yarn to resolve babel-loader version 8.1.0 (the version required by CRA, not Storybook):

"resolutions": {  "babel-loader": "8.1.0"},

After that, make sure to run yarn install to refresh your dependencies and update yarn.lock file


For anyone facing the same issue with npm. I fixed it by deleting package-lock.json, node_modules.

EDIT: Leaving babel-loader implicit version in package.json is possible by using --legacy-peer-deps param for both npm i and npm dedupe:

npm i --leagcy-peer-deps

To make sure the problem lies in corrupted dependency tree I ran:

npm ls babel-loader

Finally

npm dedupe --legacy-peer-deps

fixed the issue with wrong dependency tree.It is also applicable to webpack version mismatch issue.


Adding "babel-loader": "8.1.0" to both "devDependencies" and "dependencies" in package.json file and then doing yarn to build ,seems to work as of now.Its a known issue and has been open for nearly 2 years now https://github.com/storybookjs/storybook/issues/5183