appuri/robust-websocket

ReferenceError: navigator is not defined

catamphetamine opened this issue · 4 comments

When rendering on the server side.
It's because of the way you defined your module: you assume it's only require()d on the client side.

When rendering on the server side.

This project is only for the browser. It's specifically a wrapper around the W3C standard WebSocket class. If you want a node.js package for a client websocket, check out ws

Ok, then for those coming from Google: the workaround is global.navigator = {}

Are you trying to use webpack or browserify with this?

No, I'm just running my server-side code which happens to require() your package and this seems to trigger that function (something, navigator) evaluation.
I.e. I'm not even using your library on the server, it just happens to be require()d among the others (this is a React rendering library)