我一直在做我的react项目,如果我的电脑没有发出大量的噪音,我就无法更新或安装新的软件包。我知道这与react-dom和react-router-dom的版本有关,但我不确定修复它的最佳方法。我只是不想再把事情搞砸了任何帮助或指导都是感激的!
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: my-app@0.1.0
npm WARN Found: react@17.0.2
npm WARN node_modules/react
npm WARN peer react@"*" from @testing-library/react@11.2.7
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 react-dom@17.0.2
npm WARN node_modules/react-dom
npm WARN peer react-dom@"*" from @testing-library/react@11.2.7
npm WARN node_modules/@testing-library/react
npm WARN 1 more (the root project)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: my-app@0.1.0
npm WARN Found: react@17.0.2
npm WARN node_modules/react
npm WARN peer react@"*" from @testing-library/react@11.2.7
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 react-router-dom@5.3.0
npm WARN node_modules/react-router-dom
npm WARN react-router-dom@"^5.2.0" from the root project
删除node_modules和package-lock.json后弹出这些错误。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app@0.1.0
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 react-router-dom@5.3.0
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:
2条答案
按热度按时间aij0ehis1#
要将所有包更新到新的主版本,请全局安装npm-check-updates包:
npm install -g npm-check-updates
然后运行它:
ncu -u
这将升级package.json文件中的所有版本提示,以依赖关系和devDependencies,因此npm可以安装新的主要版本。
然后运行以下命令:
npm update
68de4m5k2#
该项目是使用旧版本的NodeJS和NPM(包管理器)设置的,因此它对依赖关系的要求比当前版本更宽松。使用较旧的项目时,可以使用CLI标志:
就像错误告诉你的一样。如果这还不够,并且项目在依赖关系方面很糟糕,您还可以使用它建议的其他标志:
这两个标志都放松了依赖项解析检查,使其更像旧版本的包管理器。
这样,您至少可以安装项目,然后可以花一些时间进行维护,以修复依赖项版本和范围不匹配的问题。