reactjsnpmmaterial-uireact-16

trying to upgrade react program from 16 to 17


I am working with an older react app that was built by someone before and I am being asked to work on it. I'd like to update it from React 16.13.1 to React 17 that way I can install Material UI v5 for access to the new features. Whenever I try 'npm install react@17.0.0 react-dom@17.0.0' terminal command I get

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: material-table@1.69.2
npm ERR! Found: @material-ui/core@4.11.0
npm ERR! node_modules/@material-ui/core
npm ERR!   peer @material-ui/core@"^4.0.0" from @material-ui/icons@4.9.1
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/lab@4.0.0-alpha.55
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 material-table@1.69.2
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/core@4.0.1
npm ERR! node_modules/@material-ui/core
npm ERR!   peer @material-ui/core@"4.0.1" from material-table@1.69.2
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!

Can someone explain what this means. How I can fix it? Will it effect any previous code written?


Solution

  • It looks like React 17 is incompatible with the current Material UI dependencies. Since you're wanting to update Material UI anyway, I would:

    1. Uninstall/delete the current Material UI, and its dependencies.
    2. Run npm install react@17.0.0 react-dom@17.0.0 again
    3. If needed, uninstall/delete other dependencies
    4. Install the new version of Material UI