Reputation: 2146
I'm surprised that googling this does not give me any results. Anyway here's my problem when using socket.io
:
When I check further, it was from socket.io index.js source file (line 28) that's causing problem:
var clientSource = read(require.resolve('socket.io-client/socket.io.js'), 'utf-8');
So require.resolve() is not a function, I suspect at first it was my node version but no, I have updated to latest and it still persists.
I'm using browserify and gulp to generate the app file.
Anyone has a a fix on this? Thanks
Upvotes: 3
Views: 2425
Reputation: 23931
To use socket.io in the browser install the client lib:
npm install socket.io-client --save
it can be imported with:
var io = require('socket.io-client');
Upvotes: 3
Reputation: 13570
browserify
implementation of require
doesn't have resolve
method.
for obvious reasons, you can't run socket.io
server inside browser. If you really want a socket.io client, you should require socket.io-client
(readme says it is browserify-compatible).
Upvotes: 13