Prior to perform any installation, the old node package ought to be removed to avoid conflicts. Some of the Node.js tools might execute Node.js as node instead of Node.js hence casing conflicts. To completely remove the old package, run this command in your Ubuntu terminal:
sudo apt-get remove –purge node
Ubuntu Package Manager
This method of installing uses apt-get so as to keep everything in one place. This enables one to know the command to uninstall when needed. To install node.js npm via apt-get, run the following commands also in Ubuntu terminal:
sudo apt-get update
sudo apt-get install nodejs
sudo 1n –s /usr/ bin/
sudo apt- get install npm
Since the package is linked as node.js and not the node name, we will have to add a symlink. If not some of the services will not work properly as they expect the node command to be available.
RECOMMENDED: How to Install Java on Ubuntu
Ubuntu Package from Node Source
This method is used to install newer version of Node, while still using apt-get. The method is similar to the one above but in this case we will be running a script to show the package manager where to get the latest version.
The commands are as follows:
curl –sL https: //
setup_5.x | sudo –E
sudo apt-get install –y
sudo 1n –s / usr/bin/
nodejs / usr/ bin/ node
Binary directly from nodejs.org
The node can be installed from nodejs.org itself. Ensure that the version installed is correct for the system. There are binaries for different versions
RECOMMENDED: How to Install JDK on Ubuntu
Regardless of the installation method used, the node –v should be run to verify the install worked correctly. If using any of the last two methods, make sure the version printed out matches the one intended to download. With the increased development of Node.js, it seems apt will be unable to keep up with the new versions. The latest one is the best choice.
Now you see how easy it is. You have no reason not install node.js on Ubuntu, follow the steps above and you end up with desired results.