3

When I run bower install socket.io bower installs just fine but when looking at the installed file there is no socket.io.js file.. the issue with that is when trying to use the bower components as dependencies in my project I can't require('socket.io') (using debowerify) because its looking for bower_components/socket.io/socket.io.js

does anyone know why this is happening and what I need to do to fix this?

this is what bower install socket.io installs

the error message I get is

Error: module "./../../bower_components/socket.io/socket.io.js" not found

John Ruddell
  • 25,283
  • 6
  • 57
  • 86

1 Answers1

3

From going through the getting started guide http://socket.io/docs/# there are two components to socket.io, one each for the server and client side code.

The client side code is separately installable from here https://www.npmjs.com/package/socket.io-client and it gives us a clue as to what is up ...

From the above we are told

A standalone build of socket.io-client is exposed automatically by the socket.io server as /socket.io/socket.io.js

So it's a little bit of magic that enables access to the client side code via the server side code which I think would explain the discrepancies with what we see in under the bower_components folder post install.

In the case of a node app using express you can reference socket.io.js on client side html simply by including it <script src="socket.io.js"></script> and then making reference a presumably global io object that is introduced by that.

Hope this helps

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
  • 1
    issue again with that is the require looks for a socket.io-client.js file instead of a socket.io.js file.. what i'm doing right now is just requiring the exact file in bower_components `require('./../../bower_components/socket.io-client/socket.io.js')` which seems to import it correctly. i'm just disappointed that I have to require the exact path for that since they have a different file name than its folder (unlike every other bower js file) – John Ruddell Apr 19 '15 at 03:25