I've been working on my react project and am unable to update or install new packages without my computer making a ton of noise. I know it has something to do with the versions of react-dom and react-router-dom but I am not sure the best way to fix it. I just don't want to screw anything up further. Any help or guidance is appreciated!
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN peer react@"*" from @testing-library/[email protected]
npm WARN node_modules/@testing-library/react
npm WARN @testing-library/react@"^11.2.2" from the root project
npm WARN 5 more (mini-create-react-context, react-dom, react-router, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"17.0.2" from [email protected]
npm WARN node_modules/react-dom
npm WARN peer react-dom@"*" from @testing-library/[email protected]
npm WARN node_modules/@testing-library/react
npm WARN 1 more (the root project)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN peer react@"*" from @testing-library/[email protected]
npm WARN node_modules/@testing-library/react
npm WARN @testing-library/react@"^11.2.2" from the root project
npm WARN 5 more (mini-create-react-context, react-dom, react-router, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@">=15" from [email protected]
npm WARN node_modules/react-router-dom
npm WARN react-router-dom@"^5.2.0" from the root project
These errors popped up after deleting node_modules and package-lock.json.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: react@undefined
npm ERR! node_modules/react
npm ERR! react@"^17.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@">=15" from [email protected]
npm ERR! node_modules/react-router-dom
npm ERR! react-router-dom@"^5.2.0" 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 /Users/cherie/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
CodePudding user response:
To update all packages to a new major version, install the npm-check-updates package globally:
npm install -g npm-check-updates
then run it:
ncu -u
this will upgrade all the version hints in the package.json file, to dependencies and devDependencies, so npm can install the new major version.
then run this :
npm update
CodePudding user response:
The project has been setup using an older version of NodeJS and NPM, the package manager, so it was more lax about dependencies than the current version. When working with older projects, you can use a CLI flag:
npm install --legacy-peer-deps
Just like the error actually tells you. If that is not enough, and the project is just bad as far as dependencies go, you can also use the other flag it's proposing:
npm install --force
Both of those flags relax the dependency resolution checks to work more like older version of the package manager.
This way, you can at least install the project and then you can spent some time on maintenance to fix the issues with mismatched dependency versions and ranges.