到NodeJS官网下载安装稳定版。
选择一款IDE,我选用的是Webstorm
app.js:
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<h1>Node.js</h1>');
res.end('<p>Hello World</p>');
}).listen(3000);
console.log("HTTP server is listening at port 3000.");
在命令行中键入node app.js
访问http://127.0.0.1:3000
顺利的话会在浏览器中显示如下内容: