Wednesday, 26 April 2017

Running sockets.io in node without sudo access

I have a socket.io node file that starts like this...

//sockets/server
var app = require('http').createServer(handler)
var io = require('socket.io')(app);
var fs = require('fs');
app.listen(80); //the 5th line that the error refers to

When I run from the console with "node myFile.js" I get the following error...

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: listen EACCES
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1112:19)
    at listen (net.js:1155:10)
    at Server.listen (net.js:1240:5)
    at Object.<anonymous> (/home/myUser/node/myFile.js:5:5)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

I can easily get around the error on my local machine (MAMP) by adding 'sudo' to the start of the command, but my hosting provider won't let me do that on the production environment.

Does anyone have any idea of a way to fix the error (or even know what it means) as opposed to sudoing it out of the way?



via d3wannabe

No comments:

Post a Comment