Ubuntu – Installing node with apt-get or downloading the Linux Binaries (.tar.gz)

14.04aptnodejssoftware installation

What is the difference between installing node.js with 'sudo apt-get install nodejs' or downloading the Linux Binaries (.tar.gz) and following these instructions?

Is the outcome the same?

Best Answer

Installing from source has one pitfall, that removing (and otherwise keeping track of installed files) becomes difficult. It's best to let the package manager handle the installation. You can use this PPA and then apt-get will get you the latest version.

sudo add-apt-repository ppa:chris-lea/node.js 
sudo apt-get update
sudo apt-get install nodejs

The PPA has since been moved to another source. The instructions from the NodeJS Github wiki:

curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs

The commands, condensed out from the script:

sudo apt-get install apt-transport-https lsb-release curl 
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
sudo sh -c "echo 'deb https://deb.nodesource.com/node $(lsb_release -sc) main' > /etc/apt/sources.list.d/nodesource.list"
sudo sh -c "echo 'deb-src https://deb.nodesource.com/node $(lsb_release -sc) main' >> /etc/apt/sources.list.d/nodesource.list"
sudo apt-get update
sudo apt-get install nodejs
Related Question