Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRA & Storybook webpack clash #6505

Closed
firaskrichi opened this issue Apr 12, 2019 · 75 comments
Closed

CRA & Storybook webpack clash #6505

firaskrichi opened this issue Apr 12, 2019 · 75 comments
Labels
Projects

Comments

@firaskrichi
Copy link

CRA 2.1.5 & Storybook webpack clash - I tried with the latest alpha v of storybook v5.1.0-alpha.25 and the stable version and the problem happens in both

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:
  "webpack": "4.28.3"
Don't try to install it manually: your package manager does it automatically.
@CodeByAlex CodeByAlex added the cra Prioritize create-react-app compatibility label Apr 12, 2019
@shilman
Copy link
Member

shilman commented Apr 12, 2019

@mrmckeb Is this related to #5308?

@shilman shilman added this to the 5.1.0 milestone Apr 12, 2019
@mrmckeb
Copy link
Member

mrmckeb commented Apr 15, 2019

@shilman, it may require a similar fix.

@firaskrichi, can you please run npm ls webpack and paste the results?

@baptooo
Copy link

baptooo commented Apr 15, 2019

Hello, I am having the same issue here, I am giving you the result of npm ls webpack

├─┬ @storybook/react@5.0.6
│ ├─┬ @storybook/core@5.0.6
│ │ └── webpack@4.30.0  deduped
│ └── webpack@4.30.0
└─┬ react-scripts@2.1.8
  └── webpack@4.28.3

@firaskrichi
Copy link
Author

@shilman is there an easy workaround we could do until this is fixed maybe? A version that's likely to work?

@shilman
Copy link
Member

shilman commented Apr 26, 2019

I'm not sure, @mrmckeb is the expert here! Happy to prioritize a release this to get it fixed for CRA users!

@stale
Copy link

stale bot commented May 17, 2019

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!

@stale stale bot added the inactive label May 17, 2019
@shilman shilman removed the inactive label May 17, 2019
@yairEO
Copy link
Contributor

yairEO commented May 30, 2019

I have the same issue :(

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

  "webpack": "4.29.6"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
▶ npm ls webpack 
bar@1.0.0 /Users/foo/projects/bar
├─┬ @storybook/react@5.0.11
│ ├─┬ @storybook/core@5.0.11
│ │ └── webpack@4.32.2  deduped
│ └── webpack@4.32.2 
└─┬ react-scripts@3.0.1
  └── webpack@4.29.6 

Require assistance please...have no idea how to fix this

@firaskrichi
Copy link
Author

@mrmckeb what do you advise doing here?

@shilman shilman modified the milestones: 5.1.0, 5.1.x Jun 5, 2019
@john-bell-gw
Copy link

john-bell-gw commented Jun 11, 2019

I'm also having this problem and I'd really appreciate some help.

▶ npm ls webpack 
...
├─┬ @storybook/react@5.2.0-alpha.23
│ ├─┬ @storybook/core@5.2.0-alpha.23
│ │ └── webpack@4.33.0  deduped
│ └── webpack@4.33.0 
└─┬ react-scripts@3.0.1
  └── webpack@4.29.6 

In the meantime I have added this to my package.json and run yarn install. I'm not sure if this is a good fix, but it seems to work.

  "resolutions": {
    "webpack": "4.29.6"
  },

@stale
Copy link

stale bot commented Jul 2, 2019

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!

@stale stale bot added the inactive label Jul 2, 2019
@annakjet
Copy link

So far I have found only one solution: add SKIP_PREFLIGHT_CHECK=true to .env, but that is more of a band-aid rather than an actual solution. Unfortunately, using yarn is not an option, since the company does not want to switch to it.

Anybody has any ideas on how to deal with this?

@stale stale bot removed the inactive label Jul 16, 2019
@annakjet
Copy link

Actually, found a solution: all I had to do was move the react-scripts dependency from devDependencies to reg dependencies.

@mrmckeb
Copy link
Member

mrmckeb commented Jul 22, 2019

Hi all, you need to have react-scripts in dependencies, not devDependencies. This is how it installs by default.

If you're seeing versioning issues, try removing your node_modules and lock file, and reinstalling. This should resolve most issues.

@stale
Copy link

stale bot commented Aug 12, 2019

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!

@stale stale bot added the inactive label Aug 12, 2019
@seantcoyote
Copy link

seantcoyote commented Sep 7, 2019

I'm still seeing this issue with react-scripts 3.1.1 and storybook 5.1.11 when I add Storybook to an existing project. I'm not using devDependencies, so that's not the issue, and using the resolutions property in package.json doesn't work.

The one solution that does work is to use yarn instead of npm to install dependencies, presumably due to its superior dependency resolution abilities. If I create a new CRA project, however, and add Storybook there's no conflict when installing with npm (or yarn).

The output of npm ls webpack in my existing project:

├─┬ @storybook/react@5.1.11
│ ├─┬ @storybook/core@5.1.11
│ │ ├─┬ corejs-upgrade-webpack-plugin@2.2.0
│ │ │ └── webpack@4.39.3  deduped
│ │ └── webpack@4.39.3  deduped
│ └── webpack@4.39.3
└─┬ react-scripts@3.1.1
  └── webpack@4.39.1

The output of npm ls webpack in my new test project:

├─┬ @storybook/react@5.1.11
│ ├─┬ @storybook/core@5.1.11
│ │ ├─┬ corejs-upgrade-webpack-plugin@2.2.0
│ │ │ └── webpack@4.39.1  deduped
│ │ └── webpack@4.39.1  deduped
│ └── webpack@4.39.1
└─┬ react-scripts@3.1.1
  └── webpack@4.39.1  deduped

As you can see, I'm using the exact same versions of react-scripts and storybook in both projects, yet in my existing project storybook is using webpack@4.39.3, whereas it's using webpack@4.39.1 in the new test project.

@IvanKovnovic
Copy link

Same issue here... :(

Just tried to add current storybook/react@5.2.1 to my existing CRA-app (react-scripts@3.1.1). Both are dependencies, not devDependencies.

Using yarn instead of npm is not possible, so I don't know what to do... (except of unwillingly adding the SKIP_PREFLIGHT_CHECK flag 😒)

Shouldn't be there a mass of people encountering the same problem? Trying to add the current storybook/react version to a CRA-app seems quite common for me

@shilman shilman modified the milestones: 5.1.x, 5.2.x Sep 23, 2019
@ndelangen
Copy link
Member

@mrmckeb could we possibly take a look together, I could use some more information about how CRA does thinks and how we could improve the situation so this happens less often.. 🙇

@shilman shilman removed this from the 5.3.x milestone Jul 30, 2020
@RoeelCohen
Copy link

Same issue:

+-- @storybook/addon-storyshots@5.3.18
| `-- @storybook/core@5.3.18
|   +-- corejs-upgrade-webpack-plugin@2.2.0
|   | `-- webpack@4.44.1  deduped
|   `-- webpack@4.44.1  deduped
+-- @storybook/react@5.3.18
| `-- webpack@4.44.1
`-- react-scripts@3.4.2
  `-- webpack@4.42.0

The funny thing is that I copied the template of another CRA project where the correct version of storybook was installed

├─┬ @storybook/addon-storyshots@5.3.18
│ └─┬ @storybook/core@5.3.18
│   ├─┬ corejs-upgrade-webpack-plugin@2.2.0
│   │ └── webpack@4.40.2  deduped
│   └── webpack@4.40.2  deduped
├─┬ @storybook/react@5.3.18
│ └── webpack@4.40.2 
└─┬ react-scripts@3.1.2
  └── webpack@4.40.2  deduped

currently the whole org. works with npm so moving to yan might be an issue.

@aleph-naught2tog
Copy link

Me too:

├─┬ @storybook/addon-docs@6.0.4
│ └─┬ @storybook/core@6.0.4
│   └── webpack@4.44.1  deduped
├─┬ @storybook/react@6.0.4
│ └── webpack@4.44.1
└─┬ react-scripts@3.4.2
  └── webpack@4.42.0

@Alellujah
Copy link

I had the same problem and the only thing that solved was putting storybook in the devDependencies (which I guess it's fine as it is only used for development purposes by us)

"devDependencies": {
    "storybook": "^6.0.3",
    "@storybook/react": "^6.0.4",
    "@types/storybook__react": "^5.2.1",
    "@storybook/addon-actions": "^6.0.4",
    "@storybook/addon-knobs": "^6.0.4",
    "@types/storybook__addon-knobs": "^5.2.1"
}

@shilman
Copy link
Member

shilman commented Aug 13, 2020

@Alellujah You'll probably want to get rid of those @types/storybook__ packages. Storybook now has built-in types

@stale
Copy link

stale bot commented Sep 20, 2020

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!

@stale stale bot added the inactive label Sep 20, 2020
@julesvirallinen
Copy link

julesvirallinen commented Oct 12, 2020

Still happening to me

├─ react-scripts@3.4.3
│  └─ webpack@4.42.0
└─ webpack@4.44.2
 "@storybook/addon-actions": "^6.0.26",
    "@storybook/addon-essentials": "^6.0.26",
    "@storybook/addon-links": "^6.0.26",
    "@storybook/node-logger": "^6.0.26",
    "@storybook/preset-create-react-app": "^3.1.4",
    "@storybook/react": "^6.0.26",
    "react-scripts": "3.4.3",

using yarn, resolutions does nothing.

@stale stale bot removed the inactive label Oct 12, 2020
@stale
Copy link

stale bot commented Dec 25, 2020

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!

@stale stale bot added the inactive label Dec 25, 2020
@brahmdev
Copy link

brahmdev commented Jan 13, 2021

In my case, Storybook has "webpack": "^4.44.2" dependency and react-scripts has "webpack": "4.44.2" dependency in my case (difference in ^).
And the recent release from webpack was 4.44.6 and that gave me below issue.

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

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

  /<my-directory-path>/node_modules/webpack (version: 4.46.0) 

When I did yarn why webpack
then there was 2 version of webpack, 4.44.2 and 4.46.0

I added below in my package.json file to have the exact version of webpack

"resolutions": {
  "webpack": "4.44.2"
},
  

It worked for me and hope there is no issue with this solution.
I hope that helps you guys.
Reference: https://classic.yarnpkg.com/en/docs/selective-version-resolutions/

Thanks!

@stale stale bot removed the inactive label Jan 13, 2021
@shomukai
Copy link

shomukai commented Jan 15, 2021

Got the same issue.

Found a solution for npm (npm doesn't support resolutions in package.json) :
Manually add "webpack": "4.44.2" to devDependencies and run npm i fixed the issue. => This will force npm install the right version webpack and depute it, also this will update package-lock.json with the right version => so that storybook doesn't install its own version.
Then you can manually remove "webpack": "4.44.2" from devDependencies and run npm i again. package-lock.json will stay the same.

Storybook is working with any version of webpack 4.44.x and above, so should run properly.

For yarn, not sure whether it works the same way as npm or not, but add resolutions should fix it as mentioned in above posts.

By the way, react-scripts should be in dependencies, not devDependencies.

@johnnyoshika
Copy link

@shomukai's technique worked like a charm for me.

@outdoteth
Copy link

If you're using yarn then add this to package.json:

"resolutions": {
  "webpack": "4.44.2"
}

and then:

yarn install

@maxgfr
Copy link

maxgfr commented Oct 19, 2021

Problem solved with this version : https://github.com/storybookjs/storybook/releases/tag/v6.3.11

@johnnyoshika
Copy link

Version 6.3.11 worked well for me also. When I first upgraded all storybook packages manually to 6.3.11 I had trouble with some dependencies, but then I tried again with npx sb@latest upgrade instead and everything worked well.

@AlmogBaku
Copy link

Unfortunately, neither the versions 6.3.12, 6.3.11 nor @shomukai works for me :(

I'm trying every time again from scratch (no node_modules and no lock file)...

@iamgutz
Copy link

iamgutz commented Nov 30, 2021

For me the fix was the one suggested by @outdoteth
Add the packages to the resolutions in package.json, in my case the issue was 2 packages, babel-loader and webpack. So my resolutions look like:

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

IMPORTANT after adding this to the package.json you MUST run yarn install otherwise it won't work.

@stale
Copy link

stale bot commented Jan 9, 2022

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!

@stale stale bot added the inactive label Jan 9, 2022
@AlmogBaku
Copy link

this is still not fixed.

@stale stale bot removed the inactive label Jan 11, 2022
@aricma
Copy link

aricma commented Jan 17, 2022

thx @johnnyoshika
npx sb@latest upgrade && rm -rf node_modules && yarn worked for me
@AlmogBaku removing the node_modules was necessary ... it was still crashing before reinstalling everything "clean"

@aventide
Copy link

For me, either using yarn OR moving react-scripts back to regular dependencies solves the issue. Though, I don't totally understand why the default location of react-scripts is dependencies by default in CRA.

@ndelangen
Copy link
Member

Is this still an issue in 7.0 beta?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Hotlist
5.3 support
Development

No branches or pull requests