ant-design / ant-design

An enterprise-class UI design language and React UI library
https://ant.design
MIT License
92.36k stars 49.58k forks source link

vite-react初始化的项目无法使用antd #48888

Closed wanghao1993 closed 5 months ago

wanghao1993 commented 5 months ago

Reproduction link

https://github.com/wanghao1993/react-admin.git

Steps to reproduce

直接安装依赖,启动就会看到错误。

What is expected?

期望能够正常运行

What is actually happening?

只要使用组件就会报错, This error came from the "onResolve" callback registered here:

node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.js:1293:20:
  1293 │       let promise = setup({
       ╵                     ^

node_modules/.pnpm/antd@5.17.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/antd/es/notification/PurePanel.js:19:23:
  19 │ import { Notice } from 'rc-notification';
     ╵                        ~~~~~~~~~~~~~~~~~

✘ [ERROR] Failed to resolve entry for package "@ant-design/cssinjs". The package may have incorrect main/module/exports specified in its package.json. [plugin vite:dep-pre-bundle]

node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.js:1374:21:
  1374 │         let result = await callback({
       ╵                      ^
Environment Info
antd 5.17.0
React 18.2.0
System MacOs14.4.1
Browser chrome 124.0.6367.91
Wxh16144 commented 5 months ago

你的 vite config 为啥只 resolve .tsx 文件呢🤔?

     react(),
   ],
   resolve: {
-    extensions: [".tsx"],
+    // extensions: [".tsx"],
     alias: [
       {
         find: "@",
wanghao1993 commented 5 months ago

sorry. 阿西吧 低级错误-