Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite: global is undefined #154

Closed
xiaosenzhang opened this issue Feb 18, 2021 · 6 comments · Fixed by #243
Closed

vite: global is undefined #154

xiaosenzhang opened this issue Feb 18, 2021 · 6 comments · Fixed by #243

Comments

@xiaosenzhang
Copy link

vite创建的项目,用此插件会报错

@cwtuan
Copy link
Collaborator

cwtuan commented Feb 18, 2021

please provide more message

@xiaosenzhang
Copy link
Author

please provide more message

vite创建react项目
在App.jsx中 import intl from 'react-intl-universal' 后
image
image

@cheerylong
Copy link

please provide more message

vite创建react项目
在App.jsx中 import intl from 'react-intl-universal' 后
image
image

请问解决了吗?也遇到了同样的问题

@xiaosenzhang
Copy link
Author

xiaosenzhang commented Sep 26, 2021

please provide more message

vite创建react项目
在App.jsx中 import intl from 'react-intl-universal' 后
image
image

请问解决了吗?也遇到了同样的问题

我找到了两种解决方法:

  1. 直接改node_modules中的源码,把global 换成 var

image
如图,直接在项目index.html中添加script 把global挂载到window下即可

推荐使用第二中方法

@cheerylong
Copy link

我也是采用了window.global = window解决。

@cwtuan cwtuan changed the title vite创建的项目,用此插件会报错 vite: global is undefined Dec 13, 2023
@cwtuan cwtuan mentioned this issue Jan 25, 2024
@cwtuan
Copy link
Collaborator

cwtuan commented Jan 25, 2024

please use the last version [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants