I
I
ilysion_in_life2018-06-13 17:40:03
Node.js
ilysion_in_life, 2018-06-13 17:40:03

Why does Node.js not run script on VDS?

Hello, there was a problem, I transferred the project to VDS and I'm trying to run the Node.js server script
, but for some reason the script does not load, the node and npm packages are standing here, the script code is the simplest, so to speak, and does not work

var io = require('socket.io').listen(8080); 

io.sockets.on('connection', function (socket) {

  var ID = (socket.id).toString().substr(0, 5);
  var time = (new Date).toLocaleTimeString();
  socket.json.send({'event': 'connected', 'name': ID, 'time': time});
  socket.broadcast.json.send({'event': 'userJoined', 'name': ID, 'time': time});
  socket.on('message', function (msg) {
    var time = (new Date).toLocaleTimeString();
    socket.json.send({'event': 'messageSent', 'name': ID, 'text': msg, 'time': time});
    socket.broadcast.json.send({'event': 'messageReceived', 'name': ID, 'text': msg, 'time': time})
  });
  socket.on('disconnect', function() {
    var time = (new Date).toLocaleTimeString();
    io.sockets.json.send({'event': 'userSplit', 'name': ID, 'time': time});
  });
});

tell me what could be the problem, I try to run the node index.js command, but in the end nothing happens in the console

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question