Node.js學習筆記之一:入門

關於Node.js這裏不再贅述,直接開始學習

第一步下載安裝node.js  此處安裝window版本

可以在命令行裏查看版本

>node -v


編寫第一個hello world


編寫js文件helloworld.js,代碼如下:

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World,This is my first node js study!\n');}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

使用node運行:



在瀏覽器訪問:





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章