installing codemirror in react 18 version

80 Views Asked by At

installing using npm install react-codemirror2 codemirror pyodide received errors :

how to solve this error enter image description here

I am trying all such commands:

    npm install --legacy-peer-deps
     
    
     - npm WARN ERESOLVE overriding peer dependency npm WARN While
             
       resolving: [email protected] npm WARN Found: [email protected] npm    
       WARN node_modules/codemirror npm WARN   peer codemirror@"5.x" from   
       [email protected]    npm WARN   node_modules/react-codemirror2 
       npm WARN     react-codemirror2@"^7.3.0" from the root project    npm 
       WARN   2 more (react-codemirror2-react-17, the root project) npm WARN
       npm WARN Could not resolve dependency: npm WARN peer         
       codemirror@">=6.0.0" from [email protected] npm WARN    
       node_modules/react-codemirror-merge npm WARN           
       react-codemirror-merge@"4.21.24" from the root project npm ERR! code 
       ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR!  npm ERR! While
       resolving: [email protected] npm ERR! Found: [email protected] npm ERR!         
       node_modules/react npm ERR!   peer react@">=16.8.0" from         
       @uiw/[email protected] npm ERR!           
       node_modules/@uiw/react-codemirror npm ERR!             
       @uiw/react-codemirror@"4.21.24" from [email protected]  
       npm ERR!     node_modules/react-codemirror-merge npm ERR!            
       react-codemirror-merge@"4.21.24" from the root project npm ERR!      
       @uiw/react-codemirror@"4.21.24" from the root project npm ERR!   peer
       react@">=16.8.0" from [email protected] npm ERR!        
       node_modules/react-codemirror-merge npm ERR!             
       react-codemirror-merge@"4.21.24" from the root project npm ERR!   5  
       more (react-codemirror2, react-codemirror2-react-17, ...) npm ERR!   
       npm ERR! Could not resolve dependency: npm ERR! peer react@"^18.2.0" 
       from [email protected] npm ERR! node_modules/next npm ERR!   next@"14.0.3" 
       from the root project npm ERR! npm ERR! Conflicting peer dependency: 
       [email protected] npm ERR! node_modules/react npm ERR!   peer         
       react@"^18.2.0" from [email protected] npm ERR!   node_modules/next npm    
       ERR!     next@"14.0.3" 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!
          - List item

1

There are 1 best solutions below

0
Najmus Sakib On

So this is common for older react dependent packages, they declare react as their peer dependencies but only with these versions "react": ">=15.5 <=17.x". But if you think this is not a problem for your case or the package you are trying to install will also work then install with force.

npm install react-codemirror2 --force

and if possible contact that package maintainer to support the latest react or your specific case by creating an issue or you can create a pr.