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

global is not defined #4

Closed
Klerith opened this issue Oct 17, 2018 · 3 comments
Closed

global is not defined #4

Klerith opened this issue Oct 17, 2018 · 3 comments

Comments

@Klerith
Copy link

Klerith commented Oct 17, 2018

Just install this package because the ng-socket-io is not working.. this actually pass the first issue with ng-socket-io, but now I'm stuck with this :(

Uncaught ReferenceError: global is not defined
at Object../node_modules/socket.io-parser/is-buffer.js (is-buffer.js:4)
at webpack_require (bootstrap:83)
at Object../node_modules/socket.io-parser/binary.js (binary.js:8)
at webpack_require (bootstrap:83)
at Object../node_modules/socket.io-parser/index.js (index.js:8)
at webpack_require (bootstrap:83)
at Object../node_modules/socket.io-client/lib/index.js (index.js:7)
at webpack_require (bootstrap:83)
at Module../node_modules/ng-io/fesm5/ng-io.js (ng-io.js:1)
at webpack_require (bootstrap:83)

@Klerith
Copy link
Author

Klerith commented Oct 17, 2018

According to angular/angular-cli#8160 (comment):

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)

So add this on my index.html

<script>window.global = window;</script>

Or better, add this, on your polyfills.ts
(window as any).global = window;

@FriOne
Copy link
Owner

FriOne commented Oct 19, 2018

This is duplicate of #2

@FriOne
Copy link
Owner

FriOne commented Oct 19, 2018

I will try to make it at this weekends

@FriOne FriOne closed this as completed Oct 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants