question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] global is not defined

See original GitHub issue

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

- [x] report a *bug*
- [ ] request a *feature*

Current behaviour

socket.io-client doesn’t work with @angular/cli@1.5.0-rc.3 because of a dependency on node.js’ global var (seems to come from has-binary2@1.0.2, but I can’t find who maintains that versions)

Steps to reproduce (if the current behaviour is a bug)

see https://github.com/angular/angular-cli/issues/8160

Expected behaviour

Setup

  • OS:
  • browser:
  • socket.io version: 2.0.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:28
  • Comments:53 (15 by maintainers)

github_iconTop GitHub Comments

231reactions
amitportcommented, May 3, 2018

According to https://github.com/angular/angular-cli/issues/8160#issuecomment-386153833:

adding the following polyfills.ts should work in Angular@6:

// Add global to window, assigning the value of window itself.
(window as any).global = window;

In any case, this issue should not be resolved IMO, socket.io-client should either remove the implicit dependency on global, or document that a polyfill is needed (by anyone using the pre-bundled sources, not just Angular users)

(BTW where are the sources for latest has-binary2@1.0.2? maybe I could help)

29reactions
bibhas2commented, May 31, 2018

where did you put…

Put this in your polyfills.ts

(window as any).global = window
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix the ReferenceError: global is not defined error in ...
That sound simple enough to fix, just create a vite. config. [js/ts] file, add it to your SvelteKit project and define global right?...
Read more >
Uncaught ReferenceError: global is not defined #2141 - GitHub
ncaught ReferenceError : global is not defined at Object. ... It seems slightly related to the aforementioned bug.
Read more >
Uncaught ReferenceError: global is not defined - Stack Overflow
The global object is not available. Possible solution to change it to window object. Share.
Read more >
Uncaught ReferenceError: global is not defined - YouTube
Uncaught ReferenceError: global is not defined at node_modules/@walletconnect/socket-transport/dist/esm/index.jscreate a n ew filw named ...
Read more >
index.js:43 uncaught referenceerror: global is not defined
Bug report ... Following #8160 I found that it is still possible to cause the global ist not defined error without installing a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found