CentOS 下安装 git + node.js

首先 编译 git 以便可以 clone node.js

最新版git可以在 http://git-scm.com/download 下找到


wget http://kernel.org/pub/software/scm/git/git-1.7.4.1.tar.bz2
tar -xjf git-1.7.4.1.tar.bz2
cd git-1.7.4.1.tar.bz2/
./configure
make
make install


截下来下载并 编译 node.js


git clone git://github.com/joyent/node.git
cd node/
./configure
make
make install
 

As NodeJS v0.4.0 is out, I thought I’d have a play around with it (something I haven’t done in a very long time!)

Instantly I ran into problems:

$ ./configure
Traceback (most recent call last):
  File "/Users/greim/nodestuff/node/tools/waf-light", line 157, in     import Scripting
  File "/Users/greim/nodestuff/node/tools/wafadmin/Scripting.py", line 146     except Utils.WafError, e:
                         ^
SyntaxError: invalid syntax

I’m trying to install this on my Arch Desktop, which has Python version 3.1.3 installed. After some research I found that it was a compatibility issue between Python 2.x and 3.x.

I didn’t really want to remove Python 3 as I’d had dependency hell recently. Inspired by an answer on StackOverflow, I had a dig about in my /usr/bin directory to see if there was both Python v3 and Python v2 installed. Fortunately there was: /usr/bin/python2

After some trial and error, all I had to do was to edit 2 files:

/tmp/node-v0.4.0/tools/waf-light

amending the first line to read:

#!/usr/bin/env python2

and once I had run ./configure edit the first line in the Makefile to read:

WAF=python2 tools/waf-light

Simple!

Now I have Node JS version 0.4.0 running on my Arch box.



接下来可以试试看 node.js 提供的 http server的例子


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


保存为 test.js
然后执行 node test.js
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值