nodejs在linux下启动80端口报错

    nodejs在linux下启动80端口会提示如下错误:

    1. server is run,port is 80
    2. events.js:160
    3. throw er; // Unhandled 'error' event
    4. ^
    5. Error: listen EACCES 0.0.0.0:80
    6. at Object.exports._errnoException (util.js:1020:11)
    7. at exports._exceptionWithHostPort (util.js:1043:20)
    8. at Server._listen2 (net.js:1245:19)
    9. at listen (net.js:1294:10)
    10. at Server.listen (net.js:1390:5)
    11. at EventEmitter.listen (/home/mym/devdatas/nodejs/movie/node_modules/express/lib/application.js:618:24)
    12. at Object.<anonymous> (/home/mym/devdatas/nodejs/movie/app.js:25:5)
    13. at Module._compile (module.js:570:32)
    14. at Object.Module._extensions..js (module.js:579:10)
    15. at Module.load (module.js:487:32)

    原因是在linux中,1024以下的端口只有root用户才有权使用,所以启动nodejs时要加上sudo

    1. sudo node app.js

    原文出处:http://malaoshi.top/show_1C7bxqBEcYY.html