0

I am getting the following error while updating from React 17.0.1 to 17.0.2. It's not entirely clear to me why the dependencies are causing problems. I'm using npm v 7.4.

It seems that some dependencies are incompatible with react 17. Do I understand correctly? But npm shows e. g.

npm ERR!   peer react-dom@"^15.0.0 || ^16.0.0 || ^17.0.0" from react-calendly@2.0.0
npm ERR!   node_modules/react-calendly

If I think correct, React 17 should work.

Could someone explain the problem to me briefly? Is there a solution for this?

Error:

npm install --save react@17.0.2
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"17.0.2" from the root project
npm ERR!   peer react@"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from mini-create-react-context@0.4.1
npm ERR!   node_modules/mini-create-react-context
npm ERR!     mini-create-react-context@"^0.4.0" from react-router@5.2.0
npm ERR!     node_modules/react-router
npm ERR!       react-router@"5.2.0" from react-router-dom@5.2.0
npm ERR!       node_modules/react-router-dom
npm ERR!         react-router-dom@"^5.2.0" from the root project
npm ERR!   7 more (react-calendly, react-icons, react-router, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from react-dom@17.0.1
npm ERR! node_modules/react-dom
npm ERR!   peer react-dom@"^15.0.0 || ^16.0.0 || ^17.0.0" from react-calendly@2.0.0
npm ERR!   node_modules/react-calendly
npm ERR!     react-calendly@"^2.0.0" from the root project
npm ERR!   peer react-dom@"^15.5.4 || ^16.0.0 || ^17.0.0" from react-scroll@1.8.2
npm ERR!   node_modules/react-scroll
npm ERR!     react-scroll@"^1.8.2" from the root project
npm ERR!   2 more (styled-components, 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.
npm ERR!

My dependencies:

"emailjs-com": "^2.6.4",
"react": "^17.0.1",
"react-calendly": "^2.0.0",
"react-dom": "^17.0.1",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-router-scroll-top": "^0.2.1",
"react-scripts": "^4.0.3",
"react-scroll": "^1.8.2",
"styled-components": "^5.3.0",
"swiper": "^6.5.0"

I don't understand, why 17.0.0 should be working, but 17.0.2 not.

Thanks for your help.

Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
kinglycodes
  • 11
  • 1
  • 5
  • Since you're using npm 7, you will find your explanation here: https://stackoverflow.com/questions/66239691/what-does-npm-install-legacy-peer-deps-do-exactly-when-is-it-recommended-wh – Silviu Burcea May 11 '21 at 14:38

1 Answers1

0

You have dependency conflict which will create this problem.

I suggest solve using --force or --legacy-peer-deps.

So try :

npm install --save react@17.0.2 --force

OR

npm install --save react@17.0.2 --legacy-peer-deps

Reason of problem :

There is dependency conflict which means dependency not compatible with other or something similar which will create this problem.

Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
  • @kinglycodes I think this is the best solution to fix the problem. I even fixed a problem with my project earlier. Otherwise, this is a temporary solution until the company creates another package that works with a React. – Kevin M. Mansour May 11 '21 at 15:06
  • 1
    Sorry, but is not clear to me which is the right solution. And, will I have problems if I go with one or the other, if yes what problems? If a dependency depends to react 16 for example and my project depends on react 17, it seems to me that all should be working. Thanks. – Adrian Jan 27 '22 at 07:14