馬上開始我們第一個Node.js應用:“Hello World”。打開你的編輯器,創建一個hello.js文件。編寫代碼保存該文件,並通過Node.js來執行。
- 控制台輸出
1 console.log('hello, nodejs.') ;

- Web輸出
1 var http = require("http"); 2 http.createServer(function(request, response) { 3 response.writeHead(200, {"Content-Type": "text/html"}); 4 response.write("Hello World!"); 5 response.end(); 6 }).listen(8000);
打開瀏覽器地址欄輸入http://localhost:8000/,可以在網頁上看到輸出結果。
