nodejs logo

In the JavaScript-based development platform, Node.js is becoming increasingly popular. Although popular, it is surprising to find out that it is still not very easy to install node.js on Ubuntu. There are different ways to install and it depends on your requirements and customization needs. You need to know what you want before the installation.

RECOMMENDED: How To Install Java JRE and JDK on Ubuntu with Apt-Get

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/

nodejs  /usr/bin/node

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

bash –

sudo apt-get install –y


sudo 1n –s / usr/bin/

nodejs / usr/ bin/ node

Binary directly from

The node can be installed from 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.


  1. I’m attempting to completely remove and reinstall node and npm.

    1. The “–purge” cannot be copy-and-pasted, comes out as long dash.
    2. Somehow your “ln -s” command comes out as “1n -s”.
    3. Where are you expecting the user to be when doing ln -s /usr/ bin/ ?? His home directory?
    4. $ nodejs /usr/bin/node

    (function (exports, require, module, __filename, __dirname) { ELF
    SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

Leave a Reply