1. ubuntu 安裝 node.js
安裝依賴包
>>sudo apt-getinstall g++ curl libssl-dev apache2-utils
>>sudo apt-getinstall git-core
獲取node.js源文件并進行編譯安裝
>>git clone git://github.com/joyent/node.git
>>cd node
>>./configure
>>make
>>sudo make install
2. hello word編寫 ? 在任意文件夾下編寫hello.js代碼蔼卡,如下
varhttp = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
3. 運行
>>node hello.js
4. 瀏覽器運行
運行出現(xiàn)
hello World
5 安裝只需要在終端寫入一行代碼:
curl http://npmjs.org/install.sh | sh
npm安裝node擴展包同樣是一行代碼:
npm install <包名>//例:npm install express
參考
http://www.cnblogs.com/Darren_code/archive/2011/10/31/2207063.html