Search code examples
node.jsubuntu

how to install a latest version of Nodejs on Ubuntu?


I start using ubuntu (22.04.1) recently. I want to install nodejs latest version (currently v18.12.1 LTS). But my node --version showing version v12.22.9.

First I install node using sudo apt-get install nodejs. Then I re-install my node but before re-install I update my system using sudo apt update && sudo apt upgrade. But i keep getting same result. node version v12.22.9.


Solution

  • 1-Install CURL if you don't have:

    sudo apt-get install curl

    2-Run the following command to add the PPA to the Ubuntu system:

    curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\

    3-After successfully adding the PPA to the system, execute the command below to install Node on Ubuntu:

    sudo apt-get install nodejs

    4-check the version number of the installed software for node :

    node -v