
在本教程中,我将介绍 如何在主流 Linux 发行版上安装 Node.js,包括 Debian,Ubuntu,Fedora 和 CentOS 。
Node.js 在一些发行版上有预构建的程序包(如,Fedora 或 Ubuntu),而在其他发行版上你需要通过源码安装。由于 Node.js 发展比较快,建议从源码安装最新版而不是安装一个过时的预构建的程序包。最新的 Node.js 自带 npm(Node.js 的包管理器),让你可以轻松的安装 Node.js 的外部模块。
在 Debian 上安装 Node.js on
从 Debian 8 (Jessie)开始,Node.js 已被纳入官方软件仓库。因此,你可以使用如下方式安装它:
$ sudo apt-get install npm
在 Debian 7 (Wheezy) 以前的版本中,你需要使用下面的方式来源码安装:
$ sudo apt-get install python g++ make$ wget http://nodejs.org/dist/node-latest.tar.gz$ tar xvfvz node-latest.tar.gz$ cd node-v0.10.21 (replace a version with your own)$ ./configure$ make$ sudo make install在 Ubuntu 或 Linux Mint 中安装 Node.js
$ sudo apt-get install npm$ sudo ln -s /usr/bin/nodejs /usr/bin/node而 Ubuntu 中的 Node.js 可能版本比较老,你可以从 其 PPA 中安装最新的版本。
$ sudo apt-get install python-software-properties python g++ make$ sudo add-apt-repository -y ppa:chris-lea/node.js$ sudo apt-get update$ sudo apt-get install npm在 Fedora 中安装 Node.js
$ sudo yum groupinstall "Development Tools"$ wget http://nodejs.org/dist/node-latest.tar.gz$ tar xvfvz node-latest.tar.gz$ cd node-v0.10.21 (replace a version with your own)$ ./configure$ make$ sudo make install在 CentOS 或 RHEL 中安装 Node.js