dan*_*ndo 6 reactjs material-ui
当我尝试使用 npm install @material-ui/core 安装 Material UI 时,提示我很多错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: portfolio@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! react@"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
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@"*" 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/jordanhilado/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jordanhilado/.npm/_logs/2020-10-31T17_57_54_724Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
npm install --save --legacy-peer-deps @material-ui/core
Material UI 尚未正式支持 React v17,因此请谨慎使用。
小智 3
npm ERR! peer react@"^16.8.0" from @material-ui/core@4.11.0
这里的这一行提示您出了什么问题。
@material-ui/core@4.11.0期望 React 的对等依赖关系在当前允许的主要版本内(在这种情况下,他们似乎还没有添加对 React 版本 17 的支持)。
看起来您正在使用React 的最新主要17.0.1版本。目前最新版本的 Material-UI 将支持 17.0.0 以下的 React 版本。
有关版本号中“^”含义的解释,请参阅另一个堆栈溢出。
package.json 中的波浪号 (~) 和插入符号 (^) 有什么区别?
为了解决这个问题,请尝试将 React 降级到版本 16,至少在 Material-UI 添加对版本 17 的支持之前是如此。
旁注:您可能不需要它附带的所有内容,但创建 React 应用程序是开始 React 项目的好方法,而且不必担心版本控制问题。
| 归档时间: |
|
| 查看次数: |
1659 次 |
| 最近记录: |