John Ruddell
John Ruddell

Reputation: 25862

Why does bower not install socket.io.js file?

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

Upvotes: 3

Views: 1797

Answers (1)

Rob Kielty
Rob Kielty

Reputation: 8162

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

Upvotes: 3

Related Questions