-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Angular 7: Uncaught ReferenceError: global is not defined when adding package #602
Comments
Add this in your polyfills.ts
|
Same problem, I tried the suggestion by hijoncon but it doesn't solve the problem. |
@3xLogicJamesTays Can you provide a working example of this? |
Fixed by adding this to export default defineConfig({
...
define: {
"global": {},
},
}); |
Just to follow a bit further on hexcowboy's solution, for those who don't have a import { defineConfig } from 'vite'
export default defineConfig({
define: {
global: {},
},
}) |
@jamesjessian @hexcowboy This page seems to indicate Any thoughts? Like this solution seemingly works locally, but I get issues when I build for production. |
Honestly I have no idea, I gave up this framework after trying to solve this issue for so long. The |
Having the same issue, using the solution @hexcowboy gave, works only in development mode. When I try to build for the production version, it gives all sorts of errors, but if I remove the implementation it builds normally. |
I encountered the same problem 😭😭😭, and finally solved it with the following code : <!-- your index.html -->
<script>
/**
* this is a hack for dragula
* error: global is not defined
*/
var global = global || window
</script> |
it doesnt cause error when build on me. import { defineConfig } from 'vite'
export default defineConfig({
define: {
global: "window",
},
}) |
Can't do this one when using storybook
storybook 7 at least, has a long list of errors when building for production I placed the following in my main.ts file. Solution Here
|
- Fixes the issue that Amplify did not work due to missing `global`. Lets Vite resolve `global` to `window`. Reference: bevacqua/dragula#602 (comment)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis <script>
globalThis.global = globalThis;
</script> |
@amk221 this work to me. thank you |
I am building an Angular 7 app, and when i add a package
npm install dragula
and import this into thepollyfills.ts
file i get this error:When I googled it everyone says to add this
(window as any).global = window;
topollyfills.ts
I have done this and I still get the error. I also ready to delete the node_modules folder andnpm i
I have done this as well.I do not know what else to do here. can anyone please tell me some sugestions or at least explain why this would happen?
This may not be relevant but I'm going to add it as well. There is another error which wasnt there before I imported them into
pollyfills.ts
The text was updated successfully, but these errors were encountered: