pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

🐛[BUG] @ant-design/pro-field[2.14.6] 导致使用antd 4.x 版本的项目无法正常运行

Open feverdestiny opened this issue 1 year ago • 2 comments

🐛 bug 描述

项目package.json 依赖@ant-design/pro-components@ 2.4.4[email protected] 版本。重新安装依赖提示

10:26:55 AM [vite] hmr update /src/App.tsx
✘ [ERROR] No matching export in "node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/antd/es/index.js" for import "ColorPicker"

    node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@ant-design/pro-field/es/components/ColorPicker/index.js:4:9:
      4 │ import { ColorPicker as ColorPickerV5, ConfigProvider, version } fr...
        ╵          ~~~~~~~~~~~

10:27:01 AM [vite] error while updating dependencies:
Error: Build failed with 1 error:
node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@ant-design/pro-field/es/components/ColorPicker/index.js:4:9: ERROR: No matching export in "node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/antd/es/index.js" for import "ColorPicker"
    at failureErrorWithLog (/workspaces/sandbox/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1651:15)
    at /workspaces/sandbox/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1059:25
    at /workspaces/sandbox/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1527:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

排查了包依赖关系 @ant-design/pro-components 中依赖的@ant-design/pro-field 的包版本为^2.5.2,^2.5.2最终实际安装版本为2.14.6

"dependencies": {
    "@ant-design/pro-card": "^2.3.2",
    "@ant-design/pro-descriptions": "^2.2.3",
    "@ant-design/pro-field": "^2.5.2",
    ...

再次排查了之前安装的@ant-design/pro-field的包版本是2.14.2,这个版本是正常的。 现在@ant-design/pro-field默认安装的的包版本是2.14.6 对比@ant-design/pro-field2.14.22.14.6 两个版本 报错的ColorPicker/index.js 文件代码,发现2.14.6版本下代码

node_modules/@ant-design/pro-field/es/components/ColorPicker/index.js:4:9
import { ColorPicker as ColorPickerV5, ConfigProvider, version } from 'antd';

[email protected]版本下 无ColorPicker 导出。pro-componentsProTable等组件依赖了ColorPicker 组件导致启动报错。 希望修复。现在项目无法部署上线

📷 复现步骤

复线DEMO:https://codesandbox.io/p/devbox/pro-components-version-demo-f8dx9h 附录package.json依赖

  "dependencies": {
    "@ant-design/pro-components": "2.4.4",
    "antd": "^4.23.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },

🏞 期望结果

项目package.json 依赖@ant-design/pro-components@ 2.4.4[email protected] 版本 ,使用ProTable 能正常启动项目

💻 复现代码

复线DEMO:https://codesandbox.io/p/devbox/pro-components-version-demo-f8dx9h 附录package.json依赖

  "dependencies": {
    "@ant-design/pro-components": "2.4.4",
    "antd": "^4.23.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },

© 版本信息

  • ProComponents 版本: [2.4.4]
  • umi 版本
  • 浏览器环境
  • 开发环境 [mac]

🚑 其他信息

feverdestiny avatar Mar 05 '24 10:03 feverdestiny

我也遇到了同样的问题,错误提示表现为:"export 'ColorPicker' (imported as 'ColorPickerV5') was not found in 'antd'",看了下是pro-field依赖的antd版本需要5.x,但安装的是4.x,希望可以解决下

fancysh avatar Mar 15 '24 08:03 fancysh

附录我的解决方案 之前使用的版本是

  "@ant-design/pro-components": "2.4.4",

升级到2.6.42版本可用。

  "@ant-design/pro-components": "2.6.42",

再高的版本也会报错不可用 希望对后来者用

feverdestiny avatar Mar 25 '24 07:03 feverdestiny