在Mac下,如果你喜欢用homebrew,那么只用一行就可以装好:
brew install node
否则,只能考虑手工安装了,步骤如下:
安装Xcode
安装git
运行下面的命令行编译node.js
代码如下:
<BR />git clone git://github.com/ry/node.git <BR />cd node <BR />./configure <BR />make <BR />sudo make install <BR /> <BR /><STRONG>Ubuntu</STRONG> <BR />安装依赖包 <br /><br />sudo apt-get install g++ curl libssl-dev apache2-utils <BR />sudo apt-get install git-core <br /><br />运行下面的命令行: <BR /><span><U></U></span> 代码如下:<BR />git clone git://github.com/ry/node.git <BR />cd node <BR />./configure <BR />make <BR />sudo make install <BR /> <BR /><STRONG>Windows</STRONG> <br /><br />用cygwin来安装node,步骤如下: <BR />安装cygwin <BR />在cygwin的目录下,运行setup.exe安装下面列表中的包 <BR />devel → openssl <BR />devel → g++-gcc <BR />devel → make <BR />python → python <BR />devel → git <BR />运行cygwin <BR />运行下面的命令行: <BR /><span><U></U></span> 代码如下:<BR />git clone git://github.com/ry/node.git <BR />cd node <BR />./configure <BR />make <BR />sudo make install <BR /> <BR /><STRONG>Centos</STRONG> <BR /><span><U></U></span> 代码如下:<BR />yum install gcc-c++ openssl-devel <BR />wget --no-check-certificate https://github.com/ry/node/tarball/v0.3.3 <BR />tar -xzvf ry-node-v0.3.3-0-g57544ba.tar.gz <BR />cd ry-node-v0.3.3-0-g57544bac1 <BR />./configure <BR />make <BR />make install <BR /> <BR /><STRONG>Hello Node.js!</STRONG> <br /><br />写一段小程序例如hello_node.js来验证安装是否正确: <BR /><span><U></U></span> 代码如下:<BR />var http = require('http'); <BR />http.createServer(function (req, res) { <BR />res.writeHead(200, {'Content-Type': 'text/plain'}); <BR />res.end('Hello Node.jsn'); <BR />}).listen(8124, "127.0.0.1"); <BR />console.log('Server running at http://127.0.0.1:8124/'); <BR /> <BR />用node来运行这段代码 <BR /><span><U></U></span> 代码如下:<BR />node hello_node.js <BR />Server running at http://127.0.0.1:8124/ <BR /> <BR />现在,用浏览器打开 http://127.0.0.1:8124/ , 应该能够看到一条好消息。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!