【发布时间】:2022-01-19 06:26:33
【问题描述】:
我正在尝试试用最新版本的 NextJS(版本 12),以使我的项目能够访问 SSR ServerComponents 和 Http 流。
MaterialUI 可以在 Next 12.0.7 和 React 17 中正常工作(使用 npx create-next-app@latest 安装)
当我这样做时
npm install react@beta react-dom@beta
然后
npm install @mui/material @mui/styled-engine-sc styled-components --save
给予
(base) marcfielding@MBP meta-ui % npm install @mui/material @mui/styled-engine-sc styled-components --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: meta-ui@undefined
npm ERR! Found: react@18.0.0-rc.0-next-f2a59df48-20211208
npm ERR! node_modules/react
npm ERR! react@"^18.0.0-beta-24dd07bd2-20211208" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.2" from @mui/material@5.2.3
npm ERR! node_modules/@mui/material
npm ERR! @mui/material@"*" 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 /Users/marcfielding/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/marcfielding/.npm/_logs/2021-12-09T16_48_20_688Z-debug.log
这只是等待 MUI 赶上来吗?或者有没有我可以安装的版本,我之前按照here 的说明进行操作?
【问题讨论】:
-
@Summer 下面的回答非常有效。 NPM@7 有一个古怪的对等依赖解析系统,你可以在这里阅读更多ostack.cn/?qa=538022。
标签: reactjs npm material-ui next.js server-side-rendering