next.js React 18不支持的依赖项

eanckbw9  于 2023-04-11  发布在  React
关注(0)|答案(1)|浏览(148)

我目前正在学习一个教程,它是在react v18之前。我试着做我研究的事情,甚至向chatgpt寻求帮助,但我仍然无法安装create-next-app,而不需要它与以下依赖项兼容。请帮助我安装create-next-app的依赖项。我还可以问@mui/system是否是react v18中@mui/styles的替代品吗?如果不是,有吗?谢谢。

{
      "name": "my-app",
      "private": true,
      "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "lint": "next lint"
      },
      "dependencies": {
        "@emotion/react": "^11.7.1",
        "@emotion/server": "^11.4.0",
        "@emotion/styled": "^11.6.0",
        "@mui/icons-material": "^5.4.1",
        "@mui/material": "^5.4.1",
        "@mui/styles": "^5.4.1",
        "next": "12.0.10",
        "react": "17.0.2",
        "react-dom": "17.0.2"
      },
      "devDependencies": {
        "eslint": "8.9.0",
        "eslint-config-next": "12.0.10"
      }
    }
0dxa2lsx

0dxa2lsx1#

对于依赖项尝试以下操作:

"dependencies": {
    "@emotion/react": "^11.10.6",
    "@emotion/styled": "^11.10.6",
    "@mui/icons-material": "^5.11.11",
    "@mui/material": "^5.11.14",
    "next": "13.2.4",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },

或者,您可能希望运行npm命令来安装依赖项,而不是在文件中摆弄条目。尝试以下操作:
npm install @mui/system @emotion/react @emotion/styled @mui/icons-material @emotion/server @emotion/css
根据@mui/styles页面,@mui/system是@mui/styles的“推荐替代品”,因为@mui/styles是一个“遗留样式解决方案”,在Material UI v5中被弃用。

相关问题