node.js创建服务器报错

创建nodeTest.js如下:

1 var http = require('http');
2 http.createServer(function (request, response){
3     response.writeHead(200, {'Content-Type' : 'text/plain'});
4     response.end('hello world\n');
5 }).listen(80);
6 
7 console.log('server running at http://127.0.0.1:80');

在终端中输入 node nodeTest.js 始终报错:

错误原因:

已经运行的另一个服务器使用了相同的端口,换一个端口就可以了。

如把80换成8080,再次运行:

 

posted @ 2015-12-29 20:36  Raychan  阅读(354)  评论(0编辑  收藏  举报