尝试将React程序从16升级到17

问题描述 投票:0回答:1

我正在使用一个较旧的 React 应用程序,该应用程序是由某人之前构建的,并且有人要求我处理它。我想将其从 React 16.13.1 更新到 React 17,这样我就可以安装 Material UI v5 来访问新功能。每当我尝试“npm install [email protected] [email protected]”终端命令时,我都会得到

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @material-ui/[email protected]
npm ERR! node_modules/@material-ui/core
npm ERR!   peer @material-ui/core@"^4.0.0" from @material-ui/[email protected]
npm ERR!   node_modules/@material-ui/icons
npm ERR!     @material-ui/icons@"^4.9.1" from the root project
npm ERR!   peer @material-ui/core@"^4.9.10" from @material-ui/[email protected]
npm ERR!   node_modules/@material-ui/lab
npm ERR!     @material-ui/lab@"^4.0.0-alpha.55" from the root project
npm ERR!   4 more (@material-ui/pickers, @material-ui/pickers, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @material-ui/core@"4.0.1" from [email protected]
npm ERR! node_modules/material-table
npm ERR!   material-table@"^1.69.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @material-ui/[email protected]
npm ERR! node_modules/@material-ui/core
npm ERR!   peer @material-ui/core@"4.0.1" from [email protected]
npm ERR!   node_modules/material-table
npm ERR!     material-table@"^1.69.2" 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!

谁能解释一下这是什么意思。我该如何修复它?会影响之前写的代码吗?

reactjs npm material-ui react-16
1个回答
0
投票

看起来 React 17 与当前的 Material UI 依赖项不兼容。既然你无论如何都想更新材质 UI,我会:

  1. 卸载/删除当前材质 UI 及其依赖项。
  2. 再次运行 npm install [电子邮件受保护] [电子邮件受保护]
  3. 卸载/删除其他依赖项(如果需要)
  4. 安装新版Material UI
© www.soinside.com 2019 - 2024. All rights reserved.