node.js - 无法运行 NPM 安装,因为它“无法解析依赖树”
问题描述
我的 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?回到第一格并重新安装所有依赖项?
解决方案
似乎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",
推荐阅读
- powershell - 使用 new-item 创建文件夹偶尔会在 Powershell 中引发错误
- python - PyQt5 QTreeView 在检查子节点时自动折叠
- objective-c - 为什么我无法关闭 Touch ID 提示?
- android - 我以为 ANDROID_ID 永远不会改变,但我错了
- php - exec 返回 sh:-c:第 0 行:意外标记 `(' 附近的语法错误
- php - 禁用目录浏览 wamp
- python - 如何在启动 gunicorn 之前设置 Django 服务器状态
- python - 如何在 Maya 中添加事件过滤器
- ios - 如何随机移动(翻译)图片,屏幕的任何位置?
- android - Android:为什么我不能以编程方式滚动这个 WebView?