每当我尝试运行npm更新时,我都会遇到这样的错误消息
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-website@0.1.0
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR! react@"^16.8.0" from the root project
npm ERR! peer react@"^16.8.0" from @material-ui/core@4.11.0
npm ERR! node_modules/@material-ui/core
npm ERR! @material-ui/core@"^4.11.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from react-dom@17.0.1
npm ERR! node_modules/react-dom
npm ERR! react-dom@"^17.0.1" from the root project当我尝试运行npm安装时,我会在控制台中得到这个错误消息-视差。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-website@0.1.0
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR! react@"^16.8.0" from the root project
npm ERR! peer react@"16.x.x" from react-parallax@3.1.2
npm ERR! node_modules/react-parallax
npm ERR! react-parallax@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from react-dom@17.0.1
npm ERR! node_modules/react-dom
npm ERR! react-dom@"^17.0.1" 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.下面是我当前的package.json:
{
"name": "my-website",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"react": "^16.8.0",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"enzyme-to-json": "^3.6.1"
},
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"collectCoverageFrom": [
"src/**/*.js",
"!src/index.js"
],
"coverageReporters": [
"text"
]
}
}我已经尝试删除我的node_modules文件夹,npm安装,但这似乎不起作用。我没有花很多时间来处理这些类型的bug,来理解控制台到底要求我修复什么,这对我来说有点陌生。问题到底是什么,我如何解决它,以及如何阻止这种情况在未来发生?
发布于 2020-11-15 07:32:45
您能试着用npm install --legacy-peer-deps运行它吗?我认为您正在使用最新的Beta版本的npm v7。
在错误消息中也提到了这一点。
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.您可以查看更多关于测试版这里的信息。
发布于 2021-11-28 13:39:46
您可以使用npm安装-遗留-对等程序,这将自动解决所有冲突。
发布于 2022-05-04 07:42:23
如果只有npm install --force不能工作,您可以尝试这个答案。
衰落-不是一个好的做法
https://stackoverflow.com/questions/64842060
复制相似问题