material-ui: @mui/lab has a peer dependency conflict with React 18

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

It appears the lab has dependency conflict as shown below

npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @mui/x-date-pickers@5.0.0-alpha.0
npm WARN Found: react@18.0.0
npm WARN node_modules/react
npm WARN   react@"18.0.0" from the root project
npm WARN   15 more (@emotion/react, @emotion/styled, @mui/base, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^17.0.2" from @mui/x-date-pickers@5.0.0-alpha.0
npm WARN node_modules/@mui/x-date-pickers
npm WARN   @mui/x-date-pickers@"5.0.0-alpha.0" from @mui/lab@5.0.0-alpha.77
npm WARN
npm WARN Conflicting peer dependency: react@17.0.2
npm WARN node_modules/react
npm WARN   peer react@"^17.0.2" from @mui/x-date-pickers@5.0.0-alpha.0
npm WARN   node_modules/@mui/x-date-pickers
npm WARN     @mui/x-date-pickers@"5.0.0-alpha.0" from @mui/lab@5.0.0-alpha.77
npm WARN     node_modules/@mui/lab

Expected behavior πŸ€”

Possibly related to #32074. As of now, core MUI is working fine with React 18, the lab should be installed without errors too.

Steps to reproduce πŸ•Ή

Steps:

  1. npx create-next-app@latest --typescript
  2. npm install @mui/material @emotion/react @emotion/styled
  3. npm install @mui/lab

Context πŸ”¦

No response

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
System:
    OS: Windows 10 10.0.19044
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.6.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.19041.1266.0), Chromium (100.0.1185.39)
  npmPackages:
    @emotion/react: ^11.9.0 => 11.9.0
    @emotion/styled: ^11.8.1 => 11.8.1
    @mui/base:  5.0.0-alpha.76
    @mui/icons-material: ^5.6.1 => 5.6.1
    @mui/lab: ^5.0.0-alpha.77 => 5.0.0-alpha.77
    @mui/material: ^5.6.1 => 5.6.1
    @mui/private-theming:  5.6.1
    @mui/styled-engine:  5.6.1
    @mui/system:  5.6.1
    @mui/types:  7.1.3
    @mui/utils:  5.6.1
    @mui/x-date-pickers:  5.0.0-alpha.0
    @types/react: 18.0.5 => 18.0.5
    react: ^18.0.0 => 18.0.0
    react-dom: ^18.0.0 => 18.0.0
    typescript: 4.6.3 => 4.6.3

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Team if you can help on the below error , I am getting the error message in Pipeline only . but when I am running this code it is working in the local machine. I am updating my my application with latest.

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @mui/styles@5.11.2 npm ERR! Found: react@18.2.0 npm ERR! node_modules/react npm ERR! react@β€œ^18.2.0” from the root project npm ERR! peer react@β€œ>=16.8.0” from @emotion/react@11.10.5 npm ERR! node_modules/@emotion/react npm ERR! @emotion/react@β€œ^11.10.5” from the root project npm ERR! peer @emotion/react@β€œ^11.0.0-rc.0” from @emotion/styled@11.10.5 npm ERR! node_modules/@emotion/styled npm ERR! @emotion/styled@β€œ^11.10.5” from the root project npm ERR! 4 more (@mui/material, @mui/styled-engine, @mui/system, @mui/x-date-pickers) npm ERR! 4 more (@mui/material, @mui/styled-engine, @mui/system, @mui/x-date-pickers) npm ERR! 36 more (@emotion/styled, …) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@β€œ^17.0.0” from @mui/styles@5.11.2 npm ERR! node_modules/@mui/styles npm ERR! @mui/styles@β€œ^5.11.2” from the root project npm ERR! npm ERR! Conflicting peer dependency: react@17.0.2 npm ERR! node_modules/react npm ERR! peer react@β€œ^17.0.0” from @mui/styles@5.11.2 npm ERR! node_modules/@mui/styles npm ERR! @mui/styles@β€œ^5.11.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! npm ERR! See C:\Windows\ServiceProfiles\NetworkService\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Windows\ServiceProfiles\NetworkService\AppData\Local\npm-cache_logs\2023-01-13T11_24_24_174Z-debug-0.log 2023-01-13T11:24:27.0813090Z ##[warning]Couldn’t find a debug log in the cache or working directory 2023-01-13T11:24:27.1433772Z ##[error]Error: Npm failed with return code: 1 2023-01-13T11:24:27.1748242Z ##[section]Finishing: npm install

I’m also getting the same error @mui/styles is not compatible with React 18 still any updates?

@Shahzad6077 I doubt they will work on making it compatible. @mui/styles is deprecated. Find time to migrate.

⚠️ @mui/styles is the legacy styling solution for MUI. It depends on JSS as a styling solution, which is not used in the @mui/material anymore, deprecated in v5. If you don’t want to have both Emotion & JSS in your bundle, please refer to the @mui/system documentation which is the recommended alternative.

Source: https://mui.com/system/styles/basics/. It’s also discussed in #32142.

I’m seeing the same peer dependency conflict. Looks like @mui/lab has a pinned dependency on @mui/x-date-pickers (which at 5.0.0-alpha.0 is prior to the fixed 5.0.0-alpha.1):

https://github.com/mui/material-ui/blob/f3fefa246b2b17501dae69dcd1b7c8777b75e9a6/packages/mui-lab/package.json#L75

@BiancaArtola @mui/styles is not compatible with React 18.

@oliviertassinari

In that case, do you think the MUI documentation should be updated?

The documentation states, β€œv5 is the only version that fully supports React 18.” But, in the v5 migration documentation, the first step says to run the command: npm install @mui/material @mui/styles. Yet, @mui/styles does not support React 18.

Thank you for your phenomenal and highly complicated work.

@oliviertassinari is there a specific version this error does not come up in. I just did npm install @mui/lab@latest and this error still shows up.

Same answer as the first one. See the latest release, there are new versions of the packages.