skip to Main Content

I have an old react template which I want to update. I get this error:

npm update                   
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@"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.2.0 || ^17.0.0" from [email protected]
npm ERR! node_modules/react-modal-video
npm ERR!   react-modal-video@"^1.2.9" 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!
npm ERR! For a full report see:

Do you know how I can fix this?

2

Answers


  1. Your project has "react" set in its package.json to a semver range which allows it to retrieve the latest React 18.

    react-modal-video at version 1.2.10 only supports React 16 or 17, so version 18 is too high for that specific version of that package. Though it’s worth noting this is probably because it’s old and the author defined that restriction before React 18 was even available. Nonetheless, it’s better to upgrade everything to be sure.

    However, react-modal-video‘s latest version supports React 18. So probably this can be fixed by executing npm install --save react-modal-video@latest.

    Note the library may have had breaking changes since this is a major version bump (1.x.x to 2.x.x), so you may need to brace for having to change the actual code to be compatible with this new version of react-modal-video.

    To stop this kind of thing from happening in future, make sure to commit package-lock.json to version control. This will ensure the exact versions of everything installed are maintained across npm install‘s.

    Login or Signup to reply.
  2. at the first time it’s better to remove NPM and Node.js package in your system and then starting by

    npm install -g npm
    

    in CMD and installing Node.js from nodejs-website
    and after that you need to check your node.js and npm version by

    npm -v 
    

    and
    node -v
    and if cmd indicates the version of node and npm you can start coding in react by
    npx create_react_app your_project_name
    or
    npm -i -g create-react-app
    so you can install react easily

    I Hope can help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search