CentOS的软件源未包含有最新的nodejs, 需要手动编译安装。
首先安装依赖的库与工具
- yum install libtool automake autoconf gcc-c++ openssl-devel
然后下载nodejs的源码包tar, 解压缩后直接三板斧编译安装
- ./configure --prefix=/usr
- make
- make install
最后用 node -v和 npm -v 查看安装的版本
到这里其实还没完, 还需要安装 node-gyp 之类的包
- npm install -g node-gyp
npm的另一种安装方式是
- wget http://npmjs.org/install.sh
- chmod +x ./install.sh
- ./install.sh