ami*_*nrd 21 javascript npm reactjs react-quill
在使用 为我的项目安装依赖项时npm install
,我收到以下错误,但我不知道如何解释:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: soft-ui-dashboard-pro-react@3.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@"^0.14.9 || ^15.3.0 || ^16.0.0" from react-quill@1.3.5
npm ERR! node_modules/react-quill
npm ERR! react-quill@"1.3.5" 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/amin/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/amin/.npm/_logs/2022-03-23T05_47_43_419Z-debug-0.log
Run Code Online (Sandbox Code Playgroud)
这些是以下依赖项package.json
:
"dependencies": {
"@asseinfo/react-kanban": "2.2.0",
"@emotion/cache": "11.7.1",
"@emotion/react": "11.8.1",
"@emotion/styled": "11.8.1",
"@fullcalendar/daygrid": "5.10.1",
"@fullcalendar/interaction": "5.10.1",
"@fullcalendar/react": "5.10.1",
"@fullcalendar/timegrid": "5.10.1",
"@mui/icons-material": "5.4.2",
"@mui/material": "5.4.3",
"@mui/styled-engine": "5.4.2",
"@pathofdev/react-tag-input": "1.0.7",
"@react-leaflet/core": "1.1.1",
"@testing-library/jest-dom": "5.16.2",
"@testing-library/react": "12.1.3",
"@testing-library/user-event": "13.5.0",
"@three-ts/orbit-controls": "1.4.7",
"chart.js": "3.4.1",
"chroma-js": "2.4.2",
"dropzone": "5.9.3",
"flatpickr": "4.6.9",
"formik": "2.2.9",
"html-react-parser": "1.4.8",
"leaflet": "1.7.1",
"prop-types": "15.8.1",
"react": "17.0.2",
"react-chartjs-2": "3.0.4",
"react-circular-slider-svg": "0.1.5",
"react-countup": "6.1.1",
"react-dom": "17.0.2",
"react-flatpickr": "3.10.7",
"react-github-btn": "1.2.1",
"react-images-viewer": "1.7.1",
"react-leaflet": "3.2.5",
"react-quill": "1.3.5",
"react-router-dom": "6.2.1",
"react-scripts": "5.0.0",
"react-select": "5.2.2",
"react-table": "7.7.0",
"stylis": "4.0.13",
"stylis-plugin-rtl": "2.1.1",
"sweetalert2": "11.4.4",
"three": "0.121.1",
"uuid": "8.3.2",
"vanilla-tilt": "1.7.2",
"web-vitals": "2.1.4",
"yup": "0.32.11"
},
Run Code Online (Sandbox Code Playgroud)
Sur*_*iya 34
这意味着您存在依赖冲突。因此,请尝试一一运行以下选项。
1.删node_modules
除package-lock.json
然后运行
npm install
Run Code Online (Sandbox Code Playgroud)
2.或者尝试清除npm缓存
npm cache clean --force
Run Code Online (Sandbox Code Playgroud)
3. 或者使用 --legacy-peer-deps 选项运行命令
npm install --legacy-peer-deps
Run Code Online (Sandbox Code Playgroud)
4. 或者使用 --force 选项运行命令
npm install --force
Run Code Online (Sandbox Code Playgroud)
小智 31
删除node_modules
rm -rf node_modules
Run Code Online (Sandbox Code Playgroud)
设置这个
npm config set legacy-peer-deps true
Run Code Online (Sandbox Code Playgroud)
安装 npm
npm install
Run Code Online (Sandbox Code Playgroud)
请小心运行npm install <package>
with --force
, 或--legacy-peer-deps
选项,它可能会导致潜在的损坏。相反,我们应该修复依赖包之间的版本兼容性问题。
该警告意味着该react-quill@1.3.5
包需要react
兼容版本作为其对等依赖项。我们如何知道哪些版本兼容?
下面的命令将检查文件peerDependencies
中的字段package.json
。
$ npm view react-quill@1.3.5 peerDependencies
{ react: '^0.14.9 || ^15.3.0 || ^16.0.0' }
Run Code Online (Sandbox Code Playgroud)
如您所见,兼容的React
版本是:'^0.14.9 || ^15.3.0 || ^16.0.0'
。但你已经安装react: 17.0.2
在你的项目中了。这就是你收到警告的原因。
二三解决方案:
react
到那些兼容版本,您可以使用最新版本的16.x
. 您可以通过运行以下命令找到它:$ npm view react@16 version
react@16.0.0 '16.0.0'
react@16.1.0 '16.1.0'
react@16.1.1 '16.1.1'
react@16.2.0 '16.2.0'
react@16.3.0 '16.3.0'
react@16.3.1 '16.3.1'
react@16.3.2 '16.3.2'
react@16.4.0 '16.4.0'
react@16.4.1 '16.4.1'
react@16.4.2 '16.4.2'
react@16.5.0 '16.5.0'
react@16.5.1 '16.5.1'
react@16.5.2 '16.5.2'
react@16.6.0 '16.6.0'
react@16.6.1 '16.6.1'
react@16.6.2 '16.6.2'
react@16.6.3 '16.6.3'
react@16.7.0 '16.7.0'
react@16.8.0 '16.8.0'
react@16.8.1 '16.8.1'
react@16.8.2 '16.8.2'
react@16.8.3 '16.8.3'
react@16.8.4 '16.8.4'
react@16.8.5 '16.8.5'
react@16.8.6 '16.8.6'
react@16.9.0 '16.9.0'
react@16.10.0 '16.10.0'
react@16.10.1 '16.10.1'
react@16.10.2 '16.10.2'
react@16.11.0 '16.11.0'
react@16.12.0 '16.12.0'
react@16.13.0 '16.13.0'
react@16.13.1 '16.13.1'
react@16.14.0 '16.14.0'
Run Code Online (Sandbox Code Playgroud)
$ npm install react@^16.14.0 react-dom@^16.14.0 -S
Run Code Online (Sandbox Code Playgroud)
react-quill@2
,兼容react
v17,查看对等依赖关系:$ npm view react-quill@2 peerDependencies
{ react: '^16 || ^17 || ^18', 'react-dom': '^16 || ^17 || ^18' }
Run Code Online (Sandbox Code Playgroud)
peerDependencies
使其react-quill@1.3.5
兼容。