tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 215 forks source link

"Uncaught ReferenceError: global is not defined" in Angular #369

Closed billygerhard closed 4 years ago

billygerhard commented 4 years ago

When using tmi.js inside an Angular application, the TMI client is checking for global, which was removed from Angular. Angular uses window.

client.js line 7 var ws = global.WebSocket || global.MozWebSocket || require("ws");

I fix this in my index.html with

<script>
    if(window['global'] === undefined){ window['global'] = window }
</script>

but can easily be fixed with var global = global || window; before initializing ws on line 7.

Server configuration