How to uninstall material-ui and install the latest MUI?

30.5k Views Asked by At

My React APP currently has the old material-ui install.

How to uninstall it and install the latest MUI?

EDITED:

package.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"
  },
2

There are 2 best solutions below

0
crls_b On

Material UI has changed its package names in v5. In your scenario, you are migrating from v4 to v5. You can follow the Material UI migration from v4 to v5 here.

Basically you should install the new @mui packages , update your application code as needed and then you can remove old @material-ui packages.

Following that guide you should do some changes or update some components depending on your application.

0
tanbirsakib On

This is how you remove packages from your dependencies in project.json

npm uninstall --save <package_name>