3

When I try to install react-codemirror2 it gave an error and doesn't install in my app (my react version is @17.0.2) Why it doesn't install?

Error list in below

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: code-editor-with-react@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@">=15.5 <=16.x" from react-codemirror2@7.2.1
npm ERR! node_modules/react-codemirror2
npm ERR!   react-codemirror2@"*" 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.
npm ERR!
npm ERR! See C:\Users\Mahdi\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
joanis
  • 10,635
  • 14
  • 30
  • 40
Mahdi Heydari
  • 41
  • 1
  • 4
  • Looks like you've React 17 installed and `react-codemirror2` has a peer dependency on React 16 (*and maybe some of React 15*), i.e. `"react": ">=15.5 <=17.x"`. Did you try any of the suggestions from the error message? There's ***at least*** one [open issue](https://github.com/scniro/react-codemirror2/issues/271) regarding React 17 compatibility. – Drew Reese Jan 29 '22 at 08:15
  • No actually, do I have to install react@16? – Mahdi Heydari Jan 29 '22 at 08:19
  • Rolling back to React 16 may be the cleanest path forward. – Drew Reese Jan 29 '22 at 08:19

4 Answers4

1

If anyone else has the same problem like me He/she can just install "react-codemirror2-react-17" instead "react-codemirror2" It worked for me.

Mahdi Heydari
  • 41
  • 1
  • 4
1

I faced a similar error message. Try using npm install react-codemirror2 --legacy-peer-deps

0

After writing:

"engines": {
    "node": "14.x"
  }

in package.json, react-codemirror2 worked correctly

0

use " npm install react-codemirror2 --force" The only option that worked for me. You should try.