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

Uncaught ReferenceError: global is not defined #849

Open
Mathem8tic opened this issue Apr 9, 2018 · 26 comments
Open

Uncaught ReferenceError: global is not defined #849

Mathem8tic opened this issue Apr 9, 2018 · 26 comments

Comments

@Mathem8tic
Copy link

Angular 6.0.0-rc.3 and Angular-CLI 6.0.0-rc.2. Error in browser console. Will try and figure out solution and report back...

@julianobrasil
Copy link

It happens with @angular 6.0.0-rc.3 and @angular/cli 6.0.0-rc.3 too.

@julianobrasil
Copy link

julianobrasil commented Apr 11, 2018

In fact it fails with any versions combination newer than @angular 6.0.0-rc.0 + @angular/cli 1.7.4

It's working with the following combinations:
@angular 6.0.0-rc.0 + @angular/cli 1.7.4
@angular 6.0.0-rc.4 + @angular/cli 1.7.4

@julianobrasil
Copy link

This is probably the cause: angular/angular-cli#9827 (comment)

@plantsmiles
Copy link

Anyone have any luck on this?

@jvanhall
Copy link

Any update on this?

@rrajewski
Copy link

I was able to work around this for now by adding an entry for dragula to the paths in my tsconfig.json

"paths": {
      "dragula": ["../node_modules/dragula/dist/dragula.min.js"]
    }

@julianobrasil
Copy link

@rrajewski, I owe you a beer!

BTW, I put it on tsconfig.app.json (inside /src directory)

@lukica88
Copy link

lukica88 commented May 4, 2018

You can add (window as any).global = window; in polyfills.ts

@geelus
Copy link

geelus commented May 6, 2018

You can add (window as any).global = window; in polyfills.ts
worked for me. thanks

@roopeshchinnakampalli
Copy link

You can add (window as any).global = window; in polyfills.ts

Worked like charm. Thanks!

@Gerros
Copy link

Gerros commented May 18, 2018

The solution is just a workaround... Can this be solved properly?
angular/angular-cli#9827 (comment)

@amanymh
Copy link

amanymh commented May 28, 2018

<script>
var global = global || window;
var Buffer = Buffer || [];
var process = process || {
  env: { DEBUG: undefined },
  version: []
};
</script> i added this to index.html and that sove the problem

@cormacrelf
Copy link
Contributor

@Gerros unfortunately the fix will be just to integrate the workaround. Usually one would just send issues upstream to dragula (code search on both repos reveals no use of global here), but that project has not been touched in a year and I don’t think the original owner still looks at it (calling @bevacqua?). It will have to be @lukica88’s solution but in one of our source files (any one will do) with a link to this issue in a comment. (I can’t push new versions but @valorkin can.)

@cormacrelf cormacrelf reopened this Jun 11, 2018
@valorkin
Copy link
Member

@cormacrelf I can give you push access and could help to set up publish from CI
(like in ngx bootstrap)
Drop me a note if you are interested in maintaining ng2-dragula :)

Plus I can ask @bevacqua to do the same with dragula :)

@cormacrelf
Copy link
Contributor

cormacrelf commented Jun 11, 2018 via email

@cormacrelf
Copy link
Contributor

cormacrelf commented Jun 21, 2018

Also @valorkin, last publish was 1.5.0 from #636, but you don't appear to have pushed the commit changing the version number. Was there anything else you didn't push, or can just bump the version past 1.5.0 without losing anything? Ref #747 as well.

@vikbi
Copy link

vikbi commented Jul 6, 2018

adding this line in to pollyfills.ts fixed my problem if u r using angular 6

(window as any).global = window;

@cormacrelf
Copy link
Contributor

Actually, this can't be fixed in ng2-dragula. Seriously.

It would appear dragula gets loaded first, and tries to use window.global. So any polyfilling from inside the lib is too late. To fix it, you'd need to summon @bevacqua from wherever he's gone (other projects, apparently), or maintain a fork. I'm not going to maintain a fork.

I'm leaving this issue open so people can find it, and adding a note to the docs in lieu of actually solving it.

@cormacrelf cormacrelf removed this from the 2.0.0 milestone Jul 17, 2018
@cormacrelf
Copy link
Contributor

Ref
bevacqua/dragula#534

@mhadji
Copy link

mhadji commented Aug 6, 2018

adding this line in to pollyfills.ts fixed my problem if u r using angular 6

(window as any).global = window;

@Mathem8tic
Copy link
Author

Mathem8tic commented Aug 6, 2018

Thanks @mhadji, there are a couple quick fixes for this listed above similar to what you have suggested. I think this issue has morphed into a bigger conversation over time. I was able to get things working with something similar to your suggestion.

@cormacrelf
Copy link
Contributor

I'm leaving this issue open so people can find it, and adding a note to the docs in lieu of actually solving it.

Guys. I’m leaving it open. Until the polyfill is no longer necessary.

@cormacrelf cormacrelf reopened this Aug 6, 2018
@Hypenate
Copy link

Caution, I installed ng2-dragula and got this error, so I uninstalled but the error remained...
Good I pushed my code so I could reset my branch.

@alaanaeim125
Copy link

add this line in polyfills.ts

(window as any).global = window;

@exf6514
Copy link

exf6514 commented Mar 16, 2023

Any update on this? I am still getting this after upgrading to Angular 15 and I have the (window as any).global = window; line in polyfills.ts

@pparce
Copy link

pparce commented Sep 27, 2023

add this line in AppComponent constructor solved the problem in angular 16
window['global'] = window;

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

No branches or pull requests