- NodeJS下载:http://nodejs.org
- 在windows下安装完毕之后,直接在cmd中直接运行node进入命令行模式
- 输出一行Hello World
- 创建一个简单的Node Http服务器,hello.js
var http = require("http");
var httpInfo = function (req, res) {
res.writeHead(200, {'Content-Type' : 'text/html'});
res.write("Hello");
res.end("Hello");
}
http.createServer(httpInfo).listen(8080);
console.log("Http Server is Listening at port 8080");
- 运行node
- 通过浏览器 http://127.0.0.1:8080访问一下