1新建一个js文件交node_hello_001.js
2.内容如下:
var http = require("http");
function onRequest(request, response) {response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
3.在当前文件夹下打开命令行 (在当前目录按住shift键,右键点击)
4.打开浏览器输入http://localhost:8888/然后输出 Hello World
5.第一个简单的程序就完成了。