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

build Error:Could not resolve './use-prevent-globalThis' from ./use-prevent-globalThis?commonjs-external #11958

Closed
BG7ZAG opened this issue Oct 14, 2021 · 6 comments · Fixed by nuxt/framework#1835

Comments

@BG7ZAG
Copy link

BG7ZAG commented Oct 14, 2021

Environment


  • Operating System: Linux
  • Node Version: v14.18.0
  • Nuxt Version: 3-3.0.0-27235989.d52b1e8
  • Package Manager: Yarn
  • Bundler: Vite
  • User Config: meta, alias, css, vite
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

build error
Could not resolve './use-prevent-globalThis' from ./use-prevent-globalThis?commonjs-external

image

Reproduction

https://github.com/element-plus/element-plus-nuxt-starter
这个项目在我这边build也报同样错误

Additional context

No response

Logs

No response

@keithchin
Copy link

Same issue here.

Screenshot 2021-10-14 at 4 59 59 PM

@YunYouJun
Copy link
Contributor

Nuxt build seems add -globalThis for use-prevent.

@andoshin11
Copy link

andoshin11 commented Nov 9, 2021

Found out it's caused by Vite & Element Plus.

As described in here, Vite does try to convert a word global into globalThis, thus it affects a critical import statement inside Element Plus show below.

https://github.com/element-plus/element-plus/blob/66043aa3b56ecdf2f19b03c463d081800cd51c35/packages/hooks/index.ts#L9

@danielroe
Copy link
Member

closing in favour of nuxt/bridge#204

@nachtfunke
Copy link

Found out it's caused by Vite & Element Plus.

As described in here, Vite does try to convert a word global into globalThis, thus it affects a critical import statement inside Element Plus show below.

https://github.com/element-plus/element-plus/blob/66043aa3b56ecdf2f19b03c463d081800cd51c35/packages/hooks/index.ts#L9

Does that mean, renaming the file in question to anything but "global" might fix the issue? I have the same issue, but with a sass file.

@danielroe
Copy link
Member

@nachtfunke Yes, exactly. 👍

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

Successfully merging a pull request may close this issue.

6 participants