原文地址:http://howtonode.org/how-to-install-nodejs
如果你使用 homebrew 包管理工具的话,可以直接brew install node
或者用另外一种安装方式:
Install Xcode.
Install git.
运行下面的代码:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
写一个Hello Node.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 hello_node.js
Server running at http://127.0.0.1:8124/
如果安装成功访问 http://127.0.0.1:8124/ 是可以看到nodejs安装成功的界面。
附:git 安装url:http://help.github.com/mac-set-up-git/
如果你使用 homebrew 包管理工具的话,可以直接brew install node
或者用另外一种安装方式:
Install Xcode.
Install git.
运行下面的代码:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
写一个Hello Node.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 hello_node.js
Server running at http://127.0.0.1:8124/
如果安装成功访问 http://127.0.0.1:8124/ 是可以看到nodejs安装成功的界面。
附:git 安装url:http://help.github.com/mac-set-up-git/