首先,去http://nodejs.org 下載安裝。我下的版本是0.8.14。安裝很簡單,下一步下一步就哦了。
我的安裝目錄是C:\Program Files (x86)\nodejs。這時使用node -v 命令查看下安裝的版本

一、helloworld
在Node.js安裝目錄中新建一個文件hello.js,里面敲一行代碼
console.log('hello, nodejs.') ;
進入命令行控制台,進入到Node.js目錄敲node hello.js

控制台輸出了“hello, nodejs.”
二、web版的helloworld
在Node.js安裝目錄中新建一個http.js,代碼如下
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
response.write("Hello World!");
response.end();
}).listen(8000);
在命令行中啟動服務,敲 node http.js

然后打開瀏覽器地址欄輸入http://localhost:8000/,看見頁面上輸出Hello World! 就成功了。
