Skip to content

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

@billygerhard

Description

@billygerhard

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

  • Operating system: Windows 10
  • Node version (if applicable): 10.16.3
  • NPM version (if applicable): 6.13.0
  • tmi.js version: 1.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions