user172092
user172092

Reputation: 115

Issue Upgrading Material UI from v4 to v5

I'm attempting to upgrade my NextJS project from Material UI v4 to v5 using the official guide: https://mui.com/guides/migration-v4/

After following all the steps, when I start the server I get the following error in my console:

Module not found: Can't resolve 'react'

Import trace for requested module:
./../node_modules/@emotion/react/dist/emotion-react.browser.esm.js
./../node_modules/@mui/styled-engine/index.js     
./../node_modules/@mui/system/esm/index.js        
./../node_modules/@mui/core/Popper/Popper.js      
./../node_modules/@mui/core/Popper/index.js       
./../node_modules/@mui/core/index.js
./../node_modules/@mui/material/utils/index.js    
./../node_modules/@mui/icons-material/utils/createSvgIcon.js
./../node_modules/@mui/icons-material/Menu.js     
./components/global/LodAppBar.jsx
./pages/_app.jsx

I've tried deleting my node_modules folder and installing all modules fresh with no luck. I've ensured all of the @material-ui packages have been removed from my package.json file as well. These are my dependencies from package.json:

"dependencies": {
    "@auth0/auth0-react": "^1.4.0",
    "@date-io/date-fns": "^1.3.13",
    "@emotion/react": "^11.5.0",
    "@emotion/styled": "^11.3.0",
    "@mui/material": "^5.0.6",
    "@mui/styles": "^5.0.2",
    "@sentry/react": "^6.11.0",
    "@sentry/tracing": "^6.11.0",
    "babel-preset-next": "^1.4.0",
    "d3": "7.1.1",
    "date-fns": "^2.20.2",
    "date-fns-timezone": "0.1.4",
    "dotenv": "^8.2.0",
    "formik": "^2.2.6",
    "logrocket": "^2.0.0",
    "logrocket-react": "^4.0.1",
    "luxon": "^1.26.0",
    "next": "^11.1.1",
    "next-optimized-images": "^2.6.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-swipeable-views": "^0.13.9"
  },

Upvotes: 1

Views: 1429

Answers (1)

NearHuscarl
NearHuscarl

Reputation: 81310

The dependencies you provided works (at least on my machine). Try deleting yarn.lock and package-lock.json and do a fresh install again to update your packages to the newer versions.

Upvotes: 3

Related Questions