I'm using webpack v2 to bundle my app and I'm not sure why but the this in the following code block
var _global = (function() { return this; })();
returns undefined which causes the following error
Uncaught TypeError: Cannot read property 'WebSocket' of undefined
https://github.com/theturtle32/WebSocket-Node/blob/master/lib/browser.js#L1
To resolve this, I added the following code
var _global = (function() {
if (!this && typeof global !== 'undefined') {
return global;
}
return this;
})();