socketcluster-client icon indicating copy to clipboard operation
socketcluster-client copied to clipboard

global is not defined in Angular 6

Open DanielRose opened this issue 7 years ago • 1 comments

I am using this in an Angular app. After upgrading to Angular 6, I get the following error:

sctransport.js:7 Uncaught ReferenceError: global is not defined at Object../node_modules/socketcluster-client/lib/sctransport.js (sctransport.js:7) at webpack_require (bootstrap:81) at Object../node_modules/socketcluster-client/lib/scclientsocket.js (scclientsocket.js:6) at webpack_require (bootstrap:81) at Object../node_modules/socketcluster-client/index.js (index.js:1) at webpack_require (bootstrap:81) at Object../src/app/SocketClusterClient.ts (main.js:916)

The SocketClusterClient.ts is my code, and includes

import * as sc from 'socketcluster-client';

The reason is that Angular no longer includes shims for node globals. As a workaround I can manually shim it, but it would be better to solve this here.

DanielRose avatar Jun 20 '18 11:06 DanielRose

For those wondering, the shim is (<any>window).global = window. Simple enough, but should not be necessary.

seiyria avatar Mar 03 '19 21:03 seiyria