Issue
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?
Solution
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.
Answered By - adsy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.