React npm i @ant-design/ --save无法导入问题

直接 cmd 文件路径,npm i @ant-design/ --save 执行这一步会报下面的错。

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.7.5
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.15.3
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 /Users/darry/.npm/eresolve-report.txt for a full report.

解决方法:
yarn add @ant-design/。。。。
但是 非要npm解决 的话
导入这个 npm install @ant-design/charts 同样报错
其实是react版本为17时会报错 ,可以采用
npm install @ant-design/charts --legacy-peer-deps
这样就成功了

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
根据引用,在安装@ant-design/react-native时,不再需要手动链接(@ant-design/icons-react-native),而是可以使用自动链接功能。只需要使用命令`npm install @ant-design/icons-react-native --save-dev`来安装@ant-design/icons-react-native即可。此外,可以在`node_modules/@ant-design`文件夹下找到安装的文件。 根据引用,可以使用命令`react-native -v`来检查是否成功安装了react-native。 根据引用,示例代码展示了如何全局使用ant-design-mobile组件。官方文档中的示例是按需引入的,如果要全局使用,需要手动引入相应的组件文件。示例代码中引入了Button和InputItem组件,并在App组件中使用了这些组件。 所以,ant-design-mobile是一个基于React Native的UI组件库,可以通过自动链接或手动引入组件文件的方式来使用。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [react native 0.70版本使用ant-design-mobile-rn及icons字体图标库](https://blog.csdn.net/weixin_43233914/article/details/126849915)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* [react native 使用ant-design-mobile-rn的icon字体库](https://blog.csdn.net/weixin_43233914/article/details/119450451)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值