centos 5.4 安装nodejs + npm(转)

而在安装nodejs的时候,需要用到,所以需要手动安装bz2库。

sudo yum install -y bzip2*
cd Python-2.7./Modules/zlib
./configure
make
sudo make install

还需要,打开binascii模块的编译。不然在安装node的时候,会提示找不到binascii模块。

cd ../../
vi Modules/Setup.dist

找到下面的两行,将binascii前的注释去掉。

# Helper module for various ascii-encoders
#binascii binascii.c
#改成如下两行:
# Helper module for various ascii-encoders
binascii binascii.c

安装Nodejs

wget http://nodejs.org/dist/v0.6.10/node-v0.6.10.tar.gz
tar xzf node-v0.6.10.tar.gz
cd node-v0.6.10
./configure //

这个时候,会报错:

  Checking for program g++ or c++          : not found
Checking for program icpc : not found
Checking for program c++ : not found
/home/admin/pkgs/node-v0.6.10/wscript:: error: could not configure a cxx compiler!

解决办法是:
安装gcc-c++

sudo yum install gcc-c++

之后,会报错:

Checking for openssl                     : not found
Checking for function SSL_library_init : not found
Checking for header openssl/crypto.h : not found
/home/admin/pkgs/node-v0.6.10/wscript:: error: Could not autodetect OpenSSL support. Make sure OpenSSL development packages are installed. Use configure --without-ssl to disable this message.

解决办法:安装openssl-devel

sudo yum install openssl-devel

然后,就可以正常编译安装了。

./configure
make
sudo make install

nstall npm

curl http://npmjs.org/install.sh | sudo sh

提示网址有问题的话就改为curl https://npmjs.org/install.sh | sudo sh

如果提示,找不到node,所以:
再做一个软链接:

sudo ln -s /usr/local/bin/node /usr/bin/node
curl http://npmjs.org/install.sh | sudo sh

可以正常运行。

上一篇:转:Selenium之CSS Selector定位详解


下一篇:集成支付宝报一堆warning: (arm64) /Users/scmbuild/workspace/standard-pay/.....警告问题解决办法亲测可行!