var http = require('http'); function onRequest(resquest, response){ response.writeHeader(200, "Conten-Type":"text/html"); response.write('hello world'); response.end(); } http.createServer(onRequest).listen(8080);
下載nodesJS,windows下執行cmd,進入helloworld.js所在目錄,執行node helloworld.js。 html
則服務器已經啓動,瀏覽器訪問localhost:8080,便可在瀏覽器上顯示hello world; node