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

🧐[问题] module is not defined in Vite

Open textnumber085 opened this issue 3 years ago • 15 comments
trafficstars

I created a test project with yarn create vite my-react-app --template react-ts.

After everything is settled, then yarn add @ant-design/pro-components.

However when I add this page, it can not be loaded.

import { ProCard } from "@ant-design/pro-components";

const About = () => {
    return (
        <>
            <h1>About</h1>
            <ProCard title="默认尺寸" extra="extra" tooltip="这是提示" style={{ maxWidth: 300 }}>
                <div>Card content</div>
                <div>Card content</div>
                <div>Card content</div>
            </ProCard>
            <ProCard
                title="小尺寸卡片"
                extra="extra"
                tooltip="这是提示"
                style={{ maxWidth: 300, marginBlockStart: 24 }}
                size="small"
            >
                <div>Card content</div>
                <div>Card content</div>
                <div>Card content</div>
            </ProCard>
        </>
    );
};

export default About;

useHMR.js:14 Uncaught ReferenceError: module is not defined

textnumber085 avatar Sep 18 '22 15:09 textnumber085

https://github.com/ant-design/cssinjs/issues/46

sushi-su avatar Sep 19 '22 01:09 sushi-su

有没有人解决啊

1589625130 avatar Sep 22 '22 01:09 1589625130

+1,需要兼容 vite 吧

samonxian avatar Sep 23 '22 10:09 samonxian

ant-design/cssinjs#46

@sushi-su Just install @ant-design/cssinjs? still not working undefined

textnumber085 avatar Sep 25 '22 07:09 textnumber085

@textnumber085 cssinjs 用 0.0.0-alpha.45 版本

sushi-su avatar Sep 25 '22 11:09 sushi-su

怎么用啊

1589625130 avatar Sep 25 '22 12:09 1589625130

ant-design/cssinjs#46

哥,出个教程引导一下吧

1589625130 avatar Sep 25 '22 13:09 1589625130

@1589625130 ...在自己项目安装上指定版本就行 image

sushi-su avatar Sep 25 '22 13:09 sushi-su

https://github.com/QNAV/RuoYi-X-Admin 可以参考我还在开发的一个项目

sushi-su avatar Sep 25 '22 13:09 sushi-su

https://github.com/QNAV/RuoYi-X-Admin 可以参考我还在开发的一个项目 谢谢老哥

1589625130 avatar Sep 25 '22 14:09 1589625130

@textnumber085 cssinjs 用 0.0.0-alpha.45 版本

Thanks, but still...

undefined2

I'll look at your project :)

textnumber085 avatar Sep 25 '22 14:09 textnumber085

Add code snippets below to your package.json and reinstall.

pnpm:

  "pnpm": {
    "overrides": {
      "@ant-design/pro-utils>@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

yarn:

  "resolutions": {
    "@ant-design/pro-utils/**/@ant-design/cssinjs": "0.0.0-alpha.45"
  }

npm:

  "overrides": {
    "@ant-design/pro-utils": {
      "@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

Jungzl avatar Sep 26 '22 02:09 Jungzl

  "pnpm": {
    "overrides": {
      "@ant-design/pro-utils>@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

多谢大佬,完美解决

1589625130 avatar Sep 26 '22 02:09 1589625130

  "pnpm": {
    "overrides": {
      "@ant-design/pro-utils>@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

多谢大佬,完美解决

  "pnpm": {
    "overrides": {
      "@ant-design/pro-utils>@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

多谢大佬,完美解决

大佬,这段加在哪里

583540970 avatar Sep 26 '22 03:09 583540970

  "pnpm": {
    "overrides": {
      "@ant-design/pro-utils>@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

多谢大佬,完美解决

  "pnpm": {
    "overrides": {
      "@ant-design/pro-utils>@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

多谢大佬,完美解决

大佬,这段加在哪里

package.json

1589625130 avatar Sep 26 '22 03:09 1589625130

Add code snippets below to your package.json and reinstall.

pnpm:

  "pnpm": {
    "overrides": {
      "@ant-design/pro-utils>@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

yarn:

  "resolutions": {
    "@ant-design/pro-utils/**/@ant-design/cssinjs": "0.0.0-alpha.45"
  }

npm:

  "overrides": {
    "@ant-design/pro-utils": {
      "@ant-design/cssinjs": "0.0.0-alpha.45"
    }
  }

thanks! error resolved!!

textnumber085 avatar Oct 04 '22 07:10 textnumber085