🧐[问题] ProComponents 2.0文档上不是写着支持antd: >= 4.20.0 React: >= 16.9.0吗?为啥我安装的时候提示要大于React: >= 17.0.0呢?
🧐 问题描述
ProComponents 2.0文档上不是写着支持antd: >= 4.20.0 React: >= 16.9.0吗?为啥我安装的时候提示要大于React: >= 17.0.0呢?
💻 示例代码
npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: [email protected] npm ERR! Found: [email protected] npm ERR! node_modules/react npm ERR! react@"^16.10.2" from the root project npm ERR! peer react@">=16.9.0" from [email protected] npm ERR! node_modules/antd npm ERR! antd@"^4.24.15" from the root project npm ERR! peer antd@">=4.23.0 || >=5.0.0" from @ant-design/[email protected] npm ERR! node_modules/@ant-design/pro-components npm ERR! @ant-design/pro-components@"2.6.20" from the root project npm ERR! 1 more (react-dom) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@">=17.0.0" from @ant-design/[email protected] npm ERR! node_modules/@ant-design/pro-components npm ERR! @ant-design/pro-components@"2.6.20" 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! npm ERR! For a full report see:
Hi @Enzo-web! I'm Dosu and I’m helping the pro-components team.
出现这个问题的原因是:虽然 ProComponents 2.0 文档上写的是支持 React >= 16.9.0,但实际上你安装的 @ant-design/[email protected] 版本的 npm 包 peerDependencies 已经要求 React >= 17.0.0。这是因为包的依赖声明已经更新,但文档没有及时同步,导致和实际依赖不一致。
目前 ProComponents 3.x 需要 React >= 18,2.x 某些版本(比如 2.6.20)已经要求 React >= 17。如果你项目还在用 React 16,建议可以尝试安装更早的 2.x 版本(比如 2.8.10),并配合 [email protected],命令如下:
npm install @ant-design/pro-components@^2.8.10
npm install antd@^4.24.0
详细的版本要求和迁移说明可以参考官方迁移指南和 API 变更文档:迁移指南 和 API 变更。
总之,npm 的报错是因为实际包的 peerDependencies 已经要求 React 17 及以上,建议升级 React 或回退到更早的 ProComponents 2.x 版本。
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other