irpas技术客

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

未知 1411

直接 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 这样就成功了


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #npm #i #antdesign #直接 #cmd #文件路径npm