我是一个刚刚接触nodejs的菜鸟,今天在学着写一个程序的时候
var http = require("http");
var url = require("url");
function start(){
console.log("call the start");
function onRequest(request,response){
console.log("call the onRequest function");
response.writeHead(200,{"Content-type":"text/plain"});
response.write("aa");
response.end();
}
http.createServer(onRequest).listen(80);
console.log("Server has started.");
}
exports.start = start;
发现会控制台会报错
call the start
Server has started.
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: listen EACCES
at errnoException (net.js:768:11)
at Server._listen2 (net.js:891:19)
at listen (net.js:935:10)
at Server.listen (net.js:984:5)
at Object.start (/home/xing/ANodeJsWebSite/node/server.js:11:31)
at Object.<anonymous> (/home/xing/ANodeJsWebSite/node/index.js:2:8)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
而把listen的端口改成8888之后就可以成功运行了。 想请问一下各位大侠,这是为什么