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

Add React ^17.0.0 as peer dependency to support Gatsby v3 and "gatsby-plugin-netlify-cms": "^5.0.0" #5111

Closed
phipag opened this issue Mar 14, 2021 · 26 comments
Labels
ssg: gatsby type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@phipag
Copy link

phipag commented Mar 14, 2021

Describe the bug
With the release of Gatsby v3 and "gatsby-plugin-netlify-cms": "^5.0.0" the move to React 17 has been made. netlify-cms-app however requires React 16 as peer dependency. This is a request to add React 17.

To Reproduce

  1. Include gatsby-plugin-netlify-cms": "^5.0.0", and "netlify-cms-app": "^2.14.29" to your package.json
  2. Make sure you are on npm >=7.0 as this uses the new peer dependency resolution
  3. Run npm install

Expected behavior

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR!   peer react@"^16.9.0 || ^17.0.0" from [email protected]
npm ERR!   node_modules/gatsby-plugin-netlify-cms
npm ERR!     gatsby-plugin-netlify-cms@"^5.0.0" from the root project
npm ERR!   2 more (gatsby, react-dom)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.4" from [email protected]
npm ERR! node_modules/netlify-cms-app
npm ERR!   netlify-cms-app@"^2.14.29" from the root project
npm ERR!   peer netlify-cms-app@"^2.9.0" from [email protected]
npm ERR!   node_modules/gatsby-plugin-netlify-cms
npm ERR!     gatsby-plugin-netlify-cms@"^5.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Current workaround
Use the npm --legacy-peer-deps flag and install by npm install --legacy-peer-deps

@phipag phipag added the type: bug code to address defects in shipped code label Mar 14, 2021
@phipag phipag changed the title Add React ^17.0.0 as peer dependency to support Gatsby v3 and "gatsby-plugin-netlify-cms": "^5.0.0" Add React ^17.0.0 as peer dependency to support Gatsby v3 and "gatsby-plugin-netlify-cms": "^5.0.0" Mar 14, 2021
@erezrokah erezrokah added type: feature code contributing to the implementation of a feature and/or user facing functionality ssg: gatsby and removed type: bug code to address defects in shipped code labels Mar 14, 2021
@shashank-bairy
Copy link
Contributor

shashank-bairy commented Mar 23, 2021

Hi @erezrokah, I would like to work on this. How should I go about implementing this? 😄

@erezrokah
Copy link
Contributor

Hi @BA1RY thanks. I would first update all the direct and peer dependencies in all the monorepo packages and see what breaks :) Updating React might require updating other dependencies as well.

Finally this should probably be under a major version release since it's a breaking change so we would need to see if we want to include anything else under that release (maybe an emotion + slate upgrade + dropping immutable).

@shashank-bairy
Copy link
Contributor

@erezrokah So did you mean I should update all the direct and peer dependencies for all packages in https://github.com/netlify/netlify-cms/tree/master/packages to React 17? Please correct me if I'm wrong.

@erezrokah
Copy link
Contributor

@erezrokah So did you mean I should update all the direct and peer dependencies for all packages in https://github.com/netlify/netlify-cms/tree/master/packages to React 17

💯 You're correct - that would be the first step

@arpitdalal
Copy link

@erezrokah Hey, I don't mean to be rude but, when is this going to be fixed? I can't use netlify cms with [email protected] and I don't want to downgrade react to v16 because if I do, I will have to downgrade a lot of dependencies of my project and it would be just too much hassle. Is there a workaround of sorts?

@erezrokah
Copy link
Contributor

Hi @arpitdalal, the CMS is a community project so the best way to fix this is via a contribution.
A workaround is suggested in the issue description:
image

@erezrokah
Copy link
Contributor

erezrokah commented Apr 28, 2021

@BA1RY, I think we could unblock users without having to do a breaking change. As the original issue suggests we can start by updating "react": "^16.8.4" to "react": "^16.8.4 || ^17.0.0" in our peer dependencies.

Please let me know if you'd like to start with that.

@shashank-bairy
Copy link
Contributor

@erezrokah Sure, understood. I'll make the required changes.

@shashank-bairy
Copy link
Contributor

Hi @erezrokah , I've made a PR according to your instructions. Made the changes for required packages inside https://github.com/netlify/netlify-cms/tree/master/packages. Please have a look at it. Thanks

@MartinSchere
Copy link

Using the workaround I get:
Error: ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered
when including it in gatsby-config.js

@JannikWempe
Copy link

Using the workaround I get:
Error: ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered
when including it in gatsby-config.js

Same issue here using gatsby-plugin-netlify-cms@~5.4.0 and [email protected]. Excluding the plugin removes the erroer (but is obivisously not a solution).

@munawar-js
Copy link

We are also facing same issue

Error: ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered

@phipag
Copy link
Author

phipag commented Apr 30, 2021

Can confirm the issue.

@shashank-bairy
Copy link
Contributor

@erezrokah How should I go about fixing this?

@munawar-js
Copy link

munawar-js commented Apr 30, 2021 via email

@shashank-bairy
Copy link
Contributor

Thanks @munwr, that surely solves the above error. 😃
It seems like a temporary fix and I wanted to know if there were any changes to be made in my PR to solve the above error in future releases.

@MartinSchere
Copy link

@munwr @phipag I'm opening a new issue with this: #5321

@erezrokah
Copy link
Contributor

FYI, we released [email protected] and [email protected] with the fix from #5316.

Can you please verify those versions solve the issue? Once the fix is verified we'll do an official release

@shashank-bairy
Copy link
Contributor

shashank-bairy commented May 3, 2021

Hi @erezrokah , it's working for me. Used "netlify-cms-app": "2.15.0-beta.0" and "gatsby-plugin-netlify-cms": "5.3.0" inside gatsby-starter-blog and installed them using npm install --legacy-peer-deps. gatsby develop runs successfully.

@erezrokah
Copy link
Contributor

Hi @BA1RY, you should be able to install them without the --legacy-peer-deps flag using npm@7

@shashank-bairy
Copy link
Contributor

Hi @erezrokah , Just checked. It works with just npm install 😃

@phipag
Copy link
Author

phipag commented May 3, 2021

I can confirm that it works now.

@erezrokah
Copy link
Contributor

Thanks @BA1RY for taking this on and everyone else that tested it.
This should be resolved in [email protected] and [email protected] via.

Please comment it upgrading to the latest version doesn't solve it.

@dehanz13
Copy link

Hi @arpitdalal, the CMS is a community project so the best way to fix this is via a contribution.
A workaround is suggested in the issue description:
image

I tried using yarn add [email protected] [email protected] and it worked! The problem is that now i'm using yarn and npm together. Does anyone have any thoughts on how to solve this issue?

@nitishbhardwaj00
Copy link

run npm install --legacy-peer-deps and upload your package-lock.json file too it will solve the dependency error ... I have tried it on netlify

@vai0
Copy link

vai0 commented Oct 21, 2022

Is anyone else encountering this issue?

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"17.0.2" from the root project
npm ERR!   peer react@">=16.x" from @fortawesome/[email protected]
npm ERR!   node_modules/@fortawesome/react-fontawesome
npm ERR!     @fortawesome/react-fontawesome@"0.1.18" from the root project
npm ERR!   103 more (@gatsbyjs/reach-router, react-dom, @mdx-js/react, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0-0" from [email protected]
npm ERR! node_modules/netlify-cms-core/node_modules/react-split-pane
npm ERR!   react-split-pane@"^0.1.85" from [email protected]
npm ERR!   node_modules/netlify-cms-core
npm ERR!     netlify-cms-core@"^2.55.2" from [email protected]
npm ERR!     node_modules/netlify-cms-app
npm ERR!       netlify-cms-app@"2.15.72" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

It seems as though netlify-cms-app is depending on netlify-cms-core which is depending on react-split-pane -- which expects v16 while I'm on v17. I've never seen a sub-dependency depend on my top-level app's peer dependency

How is this solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ssg: gatsby type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

10 participants