Angular-socket-io, io is not defined

Anyone know solution to: io is not defined

There was a suggestion here: https://github.com/btford/angular-socket-io/issues/127

  • make sure you have socket.io client library:

      bower install socket.io-client --save
    

This didn’t fix my problem with this same error. I’m using Ionic (AngularJS)

  • including in index.html:

      script src="lib/angular-socket-io/socket.js"
    
  • in app.js

      angular.module('starter', ['ionic', 'starter.controllers', 'starter.services',       
       'starter.directives', 'btford.socket-io'])
    
  • in services.js

      .factory('seatStatusSocket',function(socketFactory){ 
         var myIoSocket = io.connect(porturl); // io is not defined here, suddenly.
    
  • It was working before, using a remote copy of the lib. When this error started, I changed index.html to link a local copy, as this remote version also received a Bad Gateway error (now fine, but still socket io is not defined as above).

removed:

script src="http://chat.socket.io/socket.io/socket.io.js"

versions

socket.io@1.3.7 node_modules/socket.io
node --version
v0.12.7
npm --version
2.11.3
nvm --version
0.25.4
ionic --version
1.7.7

I had same problem and read somewhere than socket.io-client doesn’t support bower.
For this reason, if you install this package thru bower, you should add in your bower.json following overrides to allow your build tools to include the script

“overrides”: {
“socket.io-client”: {
“main”: “socket.io.js”
}
}