macial ui 未与 npm 一起安装

问题描述 投票:0回答:1

///我的控制台

PS F:> npm install  @mui/material @emotion/react @emotion/styled
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.0.0" from the root project
npm ERR!   peer react@">=16.8.0" from @emotion/[email protected]
npm ERR!   node_modules/@emotion/react
npm ERR!     @emotion/react@"*" from the root project
npm ERR!     peerOptional @emotion/react@"^11.5.0" from @mui/[email protected]
npm ERR!     node_modules/@mui/material
npm ERR!       @mui/material@"*" from the root project
npm ERR!     1 more (@emotion/styled)
npm ERR!   1 more (@emotion/styled)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from @mui/[email protected]
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 C:\Users\SAURABH\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:\Users\SAURABH\AppData\Local\npm-cache\_logs\2022-03-31T06_00_07_287Z-debug.log

///我的npm和node版本

npm: '8.1.0',
node: '16.13.0',

///package.json 文件,包含所有依赖项

 {
      "name": "",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "@testing-library/jest-dom": "^5.16.3",
        "@testing-library/react": "^12.1.4",
        "@testing-library/user-event": "^13.5.0",
        "react": "^18.0.0",
        "react-dom": "^18.0.0",
        "react-scripts": "5.0.0",
        "web-vitals": "^2.1.4"
     },
     "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
    },
    "eslintConfig": {
       "extends": [
          "react-app",
          "react-app/jest"
       ]
    },
   "browserslist": {
      "production": [
        ">0.2%",
        "not dead",
        "not op_mini all"
      ],
      "development": [
        "last 1 chrome version",
        "last 1 firefox version",
        "last 1 safari version"
     ]
    }
  }

///我刚刚创建了一个react项目,想要使用material ui,但无法使用npm安装,顺便说一下,这是第一次使用material ui出现此错误。如果有人给我正确的解决方案,那将非常有帮助

reactjs npm material-ui package.json
1个回答
0
投票

1- npx create-react-app my-app --template 2-cd我的应用程序 3-默认安装:npm install @mui/material @emotion/react @emotion/styled 4-使用样式组件:npm install @mui/material @mui/styled-engine-sc styled-components

© www.soinside.com 2019 - 2024. All rights reserved.