我的 node_modules 有一些问题,所以我去删除 node_modules 并运行 npm install
。男孩是一个错误。我的项目完全搞砸了。当我运行 npm install
npm 时,它会发回:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR! react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"15.3.0 - 16.x" from react-vis@1.11.7
npm ERR! node_modules/react-vis
npm ERR! react-vis@"^1.11.7" 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/Cole/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Cole/.npm/_logs/2021-05-26T10_34_07_786Z-debug.log
有人请帮帮我!
编辑:这是我的 package.json。
{
"name": "project",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.21.1",
"npm": "^7.14.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"react-vis": "^1.11.7",
"redux": "^4.1.0",
"web-vitals": "^1.1.1"
},
"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"
]
}
}
不太确定我所做的事情是如此有害,但这是一次痛苦的经历。
运行 npm audit
时显示有 87 个漏洞。
运行 npm audit fix
和 npm audit fix --force
并不能解决任何问题。
有没有办法刷新所有的node_modules?回到第一个并重新安装所有依赖项?
答案 0 :(得分:0)
似乎 react-vis
具有 react@"15.3.0 - 16.x"
的对等依赖项。由于您有 react@17.0.2,它会抱怨。尝试改变
"react": "^17.0.2",
"react-dom": "^17.0.2",
到
"react": "^16.14.0",
"react-dom": "^16.14.0",