Share!

Install Node.js on Ubuntu

Node.js is very popular and is available in all popular Operating Systems and platforms including Ubuntu. It is also very fast-moving and some Node.js applications will require newer versions than what is currently offered by default software repository for Ubuntu or any other Linux distribution for that matter. For that you'll have to install from Personal Package Archives (PPA) repository as provided by NodeSource.

Install officially supported version of Node.js for Ubuntu

  1. Update available package list.
    $ sudo apt update
  2. Install Node.js.
    $ sudo apt install -y nodejs
  3. Install Node.js package manager(npm).
    $ sudo apt install -y npm
  4. Check installed version.
    $ nodejs -v
    v8.10.0
    $ npm -v
    3.5.2

Install latest version of Node.js on Ubuntu from PPA

  1. Add PPA for specific Node.js version via NodeSource's official PPA setup script.
    $ curl --silent --location https://deb.nodesource.com/setup_10.x  | sudo bash -

    Replace 10.x with 8.x or 9.x depending on your actual required version

    Install curl if not already installed with the following command:

    $ sudo apt update && sudo apt install -y curl
  2. Install latest Node.js from the PPA.
    $ sudo apt install -y nodejs 

    npm is automatically installed as dependency and does not require manual installation.

  3. Check installed nodejs and npm version.
    $ nodejs -v
    v10.9.0
    $ npm -v
    6.2.0