第一个nodejs程序

1、用任意文本编辑工具,如notepad++,编写如下代码,保存为test.js文件:

var http=require('http');
http.createServer(function (request,response){
        response.writeHead(200,{'Conten-Type':'text/plain'})
	response.end("Hello,world
");
}).listen(8887);
console.log('Server running at http://127.0.0.1:8887') 

  

2、打开cmd,运行该文件,命令 node D: odetestservice est.js,弹出如下页面

3、在浏览器中输入http://127.0.0.1:8887/,结果如下:

是不是超级简单呢!!!

原文地址:https://www.cnblogs.com/stin/p/8391240.html