2021-07-06 乐帮网
ant design 前端框架
参考Ant Design Pro的github地址: https://github.com/ant-design/ant-design-pro
来搭建Ant Design Pro框架的程序。
$ mkdir <your-project-name>
$ cd <your-project-name>
$ yarn create umi # or npm create umi
# Choose ant-design-pro:
Select the boilerplate type (Use arrow keys)
❯ ant-design-pro - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
app - Create project with a simple boilerplate, support typescript.
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.
$ git init
$ npm install
$ npm start # visit http://localhost:8000
在npm install安装依赖时遇到如下错误:
D:\Demo\vkt.demo.ant>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@16.14.0
npm ERR! node_modules/react
npm ERR! react@"^16.14.0" from the root project
npm ERR! peer react@">=16.9.0" from @ant-design/pro-descriptions@1.8.6
npm ERR! node_modules/@ant-design/pro-descriptions
npm ERR! @ant-design/pro-descriptions@"^1.2.0" from the root project
npm ERR! 1 more (antd)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-dom@17.0.2
npm ERR! node_modules/react-dom
npm ERR! react-dom@"^17.0.0" from the root project
npm ERR! peer react-dom@">=16.9.0" from antd@4.16.6
npm ERR! node_modules/antd
npm ERR! antd@"^4.15.0" from the root project
npm ERR! 1 more (@ant-design/pro-descriptions)
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\Administrator\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\Administrator\AppData\Local\npm-cache\_logs\2021-07-06T01_09_16_056Z-debug.log
解决办法:
放弃使用npm来下载,还是推荐使用yarn来完成。其中yarn方式在github上并没有完全体现。但是在官网有体现:https://pro.ant.design/
yarn的安装也只有条命令,非常的简单 npm install -g yarn
使用过程如下
$ yarn create umi my-app
Select the boilerplate type: Select Ant Design Pro
❯ ant-design-pro
Which language do you want to use? Select language you use
❯ TypeScript
JavaScript
$ cd my-app
$ yarn
$ yarn start # open browser and visit http://localhost:8000
中间还有一个坑,不得不说 https://registry.npm.taobao.org 有一些库更新不及时,可能会导致失败,这个时候我们可以尝试使用默认的源:https://registry.npmjs.org
设置方法如下:yarn config set registry https://registry.npmjs.org --global
lebang2020.cn希望能帮助到你。
关注我的微信公众号
在公众号里留言交流
投稿邮箱:1052839972@qq.com
庭院深深深几许?杨柳堆烟,帘幕无重数。
玉勒雕鞍游冶处,楼高不见章台路。
雨横风狂三月暮。门掩黄昏,无计留春住。
泪眼问花花不语,乱红飞过秋千去。
如果感觉对您有帮助
欢迎向作者提供捐赠
这将是创作的最大动力