$ vim firstServer.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 is running at http://localhost:8888/');
wq保存。
$ node firstNode.js
Server is running at http://localhost:8888/
此时服务已经启动。
打开浏览器访问:
http://localhost:8888