命令行窗口使用管理员身份打开,以免出现其他不可意料的错误
1. npm create umi
2. 依次选择:
-> ant-design-pro
-> Prov4
->TypeScript
->simple
->antd@4
3. npm install,出错:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: ant-design-pro@4.5.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! react@"^17.0.0" from the root project
npm ERR! peer react@">=16.9.0" from antd@4.9.4
npm ERR! node_modules/antd
npm ERR! antd@"^4.8.6" from the root project
npm ERR! peer antd@"4.x" from @ant-design/pro-form@1.10.2
npm ERR! node_modules/@ant-design/pro-form
npm ERR! @ant-design/pro-form@"^1.3.0" from the root project
npm ERR! 1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.x" from @ant-design/pro-form@1.10.2
npm ERR! node_modules/@ant-design/pro-form
npm ERR! @ant-design/pro-form@"^1.3.0" 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!
问题产生的可能原因以及对应的解决方法:
版本不支持:降低版本
权限不够:
方法一:删除C:\Users{账户}\下的npmrc文件 [未找到]
方法二:使用npm cache clean --force命令清理缓存 [无效]
方法三:使用npm install --save --legacy-peer-deps @material-ui/core命令 [未尝试]
方法四:npm install --legacy-peer-deps [未解决,出现其他错误]
可尝试:删除全局包:npm uninstall -g react,再执行npm install [未尝试]
可尝试:使用yarn来安装 [完美解决]