mac上如何裝node.js呢?

Posted by on | |

首先要安裝:
Install Xcode.
Install git.

然後執行底下的指令:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

好啦~完裝成功~簡單吧~



怎麼測試成功呢?
隨便在一個目錄裡,加入底下的程式,假設取名為:hellonode.js

hellonode.js的內容為:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

然後執行它:
node hellonode.js

再用瀏覧器指到它:
http://127.0.0.1:8124/

然後,就如你所看到的~


#=====================
您照上述的方式安裝完成了嗎?
其實可以找安裝檔就好了,我也很白痴的,裝完後才發現,
http://nodejs.org/download/


0 意見: