If you’re looking for how to upgrade an existing Node.js installation, check out my post Upgrade Node.js Using npm and n.
Note: As of 5/5/16, the latest LTS version is 4.x and the current version is 6.x.
If you see a version number in any of the commands listed, you will likely be able to simply change the number to the version that you would like.
Download the Windows Installer direct from the official web site.
Download the Macintosh Installer direct from the official web site.
Available in the Community Repository.
pacman -S nodejs npm
Includes: Linux Mint, Linux Mint Debian Edition (LMDE), elementaryOS, etc.
Node.js is available from the NodeSource Debian and Ubuntu binary distributions repository (formerly Chris Lea’sLaunchpad PPA). Support for this repository, along with its scripts, can be found on GitHub atnodesource/distributions.
NOTE: If you are using older distributions based on Ubuntu Precise or Debian Wheezy, refer to running Node.js >= 4.x on older distros.
For version 4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
For version 6.x:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
To compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
Includes: Red Hat® Enterprise Linux® / RHEL, CentOS and Fedora, etc.
For version 4.x:
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
For version 6.x:
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
Then, as root, install:
yum -y install nodejs
To compile and install native addons from npm you may also need to install build tools:
yum install gcc-c++ make# or: yum groupinstall 'Development Tools'
Alternatively, official Fedora Node.js and npm packages are available in Fedora 18 and later:
sudo yum install nodejs npm
Also alternatively, Enterprise Linux (RHEL and CentOS) users may use the Node.js and npm packages from the EPEL repository.
Install the appropriate epel-release RPM for your version (found on the EPEL repository homepage), then run:
sudo yum install nodejs npm --enablerepo=epel
Available through the ports system.
/usr/ports/www/node
Or packages on FreeBSD:
pkg_add -r node-devel
Using pkg-ng on FreeBSD
pkg install node
Available in the portage tree.
emerge nodejs
Available in the pkgsrc tree, if you want to build from source:
cd /usr/pkgsrc/lang/nodejs && make install
Alternatively, install a binary package (if available for your platform) using pkgin:
pkgin -y install nodejs
Download Node.js via openSUSE one-click.
pkgin -y install nodejs
Or build manually from pkgsrc:
cd pkgsrc/lang/nodejs && bmake install
SmartOS images come with pkgsrc pre-installed. Other illumos distributions, will require the installation of pkgsrc first if you wish to build from source.
Located in the main repository.
xbps-install -Sy nodejs