端口3000已被使用,换成其他(比如4000),就可以了。
var http = require('http');
http.createServer(function(req,res){
res.writeHead(200,{'Content-Type': 'text/html'});
res.write('<h1>Node.js<h1>');
res.end('<p>Hello World, Good Morning!</p>');
}).listen(4000);
console.log("HTTP server is listening at port 4000.");
监听端口改为4000,在浏览器中输入http://localhost:4000/,显示: