Ahh good point. Just to be safe, you can add the client library to the package.json
Vincent Le
21

I put just socket.io-client in my dependencies, which solved that problem and uncovered a new one. Deep inside the engine.io module there is a file called websocket.js the following bit of code:

if (typeof window === 'undefined') {
try {
NodeWebSocket = require('ws');
} catch (e) { }
}

Since window is not undefined, you might think that this code does nothing, but you’d be wrong. My packager (the standard React Native packager, so far as I know) goes through all the Javascript and looks for all the import and require commands, and packages them up. The ws module contains a file called WebSocket.js, which intended for Node.js and makes use of Node.js modules like url.js and http.js, which of course, do not exist in React. Deleted the above five lines fixed the problem and everything worked.

This problem, incidentally, did not occur when I built your example, only with my own project, so I am baffled.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.