I\'ve followed the exact same steps which have always previously worked for me, create application through express, place the module dependencies in the node_modules folder.
Node.js newbie here!
I am pretty sure this has been answered. Yet I kept finding problems with the src for the socket. Apparently this : was not working for me on the client side.
I've replaced the above line with this and it seems to work fine.
(Edit: although this is obvious, this link may not work depending on when you are reading this answer. Please pick the latest link from: https://cdnjs.com/libraries/socket.io)
Here is a working client side code:
On the server side (handles only 1 socket)
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var port = process.env.PORT || 8080;
app.get('/', function(req, res){
console.log("app works");
});
io.on('connection', function(socket){
socket.emit('notification', {message:"hi"});
});
http.listen(port, function(){
console.log('listening on :' + port);
});