如何卸载material-ui并安装最新的MUI?

我的 React APP 目前安装了旧的 material-ui。

如何卸载它并安装最新的 MUI?

编辑:

包.json:

  "dependencies": {
    "@material-ui/core": "^4.12.3",
    "@material-ui/icons": "^4.11.2",
    "@mui/icons-material": "^5.0.1",
    "@reduxjs/toolkit": "^1.6.1",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^12.0.0",
    "@testing-library/user-event": "^13.2.1",
    "axios": "^0.21.1",
    "dotenv": "^10.0.0",
    "object-hash": "^2.2.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-icons": "^4.3.1",
    "react-redux": "^7.2.4",
    "react-router": "^5.2.1",
    "react-router-dom": "^5.2.1",
    "react-scripts": "4.0.3",
    "redux": "^4.1.1",
    "sass": "^1.38.2",
    "socket.io-client": "^4.1.3",
    "timeago.js": "^4.0.2",
    "web-vitals": "^2.1.0"
  },
stack overflow How to uninstall material-ui and install the latest MUI?
原文答案

答案:

作者头像

//这是从 project.json 中的依赖项中删除包的方式

npm 卸载 --save

作者头像

Material UI 在 v5 中更改了其包名称。在您的方案中,您正在从 v4 迁移到 v5。您可以关注 Material UI migration from v4 to v5 here

基本上你应该安装新的 @mui 包,根据需要更新你的应用程序代码,然后你可以删除旧的 @material-ui 包。

按照该指南,您应该根据您的应用程序进行一些更改或更新一些组件。