电脑上安装node.js
创建一个js文件(server.js),内容如下:
var http = require("http");
http.createServer(function(request,response){
response.writeHead(200,{'Content-Type':'text/plain'});
response.end('hello world\n');
}).listen(8888);
console.log('Server running at
http://127.0.0.1:8888');
进入js文件的目录,cmd运行node server.js;出现Server running at
http://127.0.0.1:8888字样,说明启动成功
在浏览器访问http://127.0.0.1:8888