安装Node.js到Ubuntu 14.04操作系统中

与CentOS类似,以下为在Ubuntu上的安装步骤记要。

从标准存储库中获取

提供的是标准套件,但如果按照常规安装,会变成一个名为nodejs的命令,这会带来困扰。

$ sudo apt-get update
$ sudo apt-get install nodejs npm
$ node
node : command not found 

所以,使用update-alternatives将命令名设置为node。使用ln做这个操作可能不太合适。

$ sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
$ node -v
v0.10.25

感觉这个版本稍微有点旧了。

从PPA软件仓库中

PPA(个人软件包档案)的简称。志愿者为我们提供了最新版本。

$ sudo add-apt-repository ppa:chris-lea/node.js 
$ sudo apt-get update
$ sudo apt-get install nodejs npm
$ node -v
v0.10.32

喜欢新鲜事物的人,也许这边更好。