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.
4
Answers
Don’t use the distribution’s default, Ubuntu is extremely conservative with bumping versions of things like Node, so instead go with Node’s repository.
The current location is documented in the installer instructions:
Where the
setup_
scripts usually do a good job of getting everything properly sorted.For the 18 LTS version:
I would use nvm – Node Version Manager, see https://github.com/nvm-sh/nvm#install–update-script
This has a couple of advantages: you don’t change the system’s node version (which might be used elsewhere) and you may select a distinct (older or newer) version of node accompanied by appropriate installations of npm, yarn, a.s.o. It’s simple to install "global" packages just locally (kind of oxymoron…) for your user. You don’t need root permission for these.
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
The current LTS version can be installed via
In difference to the already provided answers, this evergreen link will always install the current long term supported version. So you don’t need to tweak your script every couple month.