How to install Node.js on Ubuntu?

  1. Open the Terminal by either searching for it in the launcher or by using the shortcut Ctrl + Alt + T.

  2. Update your system by running the command:

    1
    sudo apt update
  3. Install the prerequisite packages that are needed to run Node.js:

    1
    sudo apt install curl wget
  4. Download and install the Node.js package by running the following commands. Replace the XX with the version number you wish to install.

    1
    2
    curl -sL https://deb.nodesource.com/setup_XX.x | sudo -E bash -
    sudo apt install -y nodejs

For example, if you want to install version 14, you would enter:

1
2
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install -y nodejs
  1. Verify the installation using the following command:
    1
    node -v
    This should display the version number of Node.js that you have installed on your system.

That’s it! You have successfully installed Node.js on your Ubuntu system.