无法使用 npm 安装 @material-ui/core

Fre*_*eon 3 npm material-ui

我尝试安装 @material-ui/core libbrary 但 npm 抛出以下错误

我用的是

npm install @material-ui

命令

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: school-demo@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from @material-ui/core@4.11.0
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/core@"*" 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 /home/freduah/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/freduah/.npm/_logs/2020-11-02T14_50_03_045Z-debug.log
freduah@freduah:~/school-demo$ ```
Run Code Online (Sandbox Code Playgroud)

小智 8

我也遇到过同样的问题。这些对我有用:

  1. 对于核心:npm -f install @material-ui/core

  2. 对于图标:npm -f install @material-ui/icons


小智 6

您可以尝试通过添加“-f”来强制安装它:

npm install -f @material-ui/core
Run Code Online (Sandbox Code Playgroud)