Can't load socket.io using node.js: io is not defined
<p>I generated an express app by using express-generator and when including socket.io I've noticed that socket.io client is not being loading by the browser. I've been 2 days searching on the internet for a solution with no success.</p>

<p>I followed socket.io instructions for express 3/4 and in fact the socket.io client that is exposed by the server on /socket.io/socket.io.js is being served (no 404 errors).
<strong>The problem is that when javascript code that tries to use socket io client fails because "io is not defined"</strong></p>

<p><strong>Any ideas about why the browser is not loading the client although it states that HTTP GET to <a href="http://localhost:8080/socket.io/socket.io.js" rel="nofollow">http://localhost:8080/socket.io/socket.io.js</a> returns HTTP 200?</strong></p>

<p>By the way, the app is also using Angular.js.</p>

<p>index.html</p>

<pre><code>&lt;script src="http://localhost:8080/socket.io/socket.io.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
 // Uncaught ReferenceError: io is not defined
 var socket = io.connect('http://localhost:8080');
&lt;/script&gt;
</code></pre>

<p>app.js (no error logs and socket.io server debug message says " socket.io:server serve client source +3s")</p>

<pre><code>// setup server
app.set('port', process.env.PORT || 8080);

var server = require('http').Server(app);
var io = require('socket.io')(server);

console.log(app.get('port'));

server.listen(app.get('port'),  function() {
  console.log('Express server listening on port ' + server.address().port);

});


io.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});
</code></pre>

<p><strong>Update:</strong></p>

<p>By using socket.io CDN the result is the same. It does not work</p>

<pre><code>&lt;script src="https://cdn.socket.io/socket.io-1.4.5.js"&gt;&lt;/script&gt;
</code></pre>