I'm pretty new to Ubuntu. I could install Node.js to the latest version 14.7.0 but the program I'm using (Jhipster) tells me that I need to install the Long Term Support (LTS, currently 12.18.3) and do not have any idea about how to do it.
There is the node-v12.18.3-linux-x64.tar.xz file that looks like a zip file in Windows, but I do not know how to install it (it does not install itself when the file manager opens it)
I tried to google on how to choose the version, but I could find how to do it. Please, explain it for dummies. Thanks.
64 Answers
To update nodejs to 14.x run the following commands:
sudo apt update
curl -sL | sudo bash -
sudo apt install -y nodejs
node -vAfter running the final command you should see:
v14.15.0 3 curl -o- | bash
source ~/.bashrc
nvm list-remote
nvm install v14.17.6In last command choose the version you want to install from list shown in previous command.
I followed the instructions from Ahmed Boutaraa's answer, which work fine, but I just did some changes to get the current LTS version.
I just changed the version of node in step 2 from:
curl -sL | sudo bash -to:
curl -sL | sudo bash -Now I run:
node -vAnd the version is:
v16.14.2 Update for 2022
Since this question was posted, version 16 became the newest LTS version. So Ahmed Boutaraa's answer is correct for the version 14 part of the question, but people stumbling on this question may be seeking the most recent LTS. If you follow those instructions, you will be stuck in version 14.
Luckily, NodeSource also provides an installation script that installs the current LTS rather than a specific version. That should make this answer a bit more future-proof. You can also get the same info straight from the source.
How to install the latest LTS version
This set of instructions will install whatever version is the latest LTS version. When a new version is released, you may have to run these instructions again to pull the new install script for the new version.
# As a user with sudo
curl -fsSL | sudo -E bash -
sudo apt-get install -y nodejs
# As root
curl -fsSL | bash -
apt-get install -y nodejsHow to install the latest non-LTS version
This set of instructions will install whatever version is the latest non-LTS version. When a new version is released, you may have to run these instructions again to pull the new install script for the new version.
# As a user with sudo
curl -fsSL | sudo -E bash -
sudo apt-get install -y nodejs
# As root
curl -fsSL | bash -
apt-get install -y nodejsHow to lock into v17 (latest, for now)
# As a user with sudo
curl -fsSL | sudo -E bash -
sudo apt-get install -y nodejs
# As root
curl -fsSL | bash -
apt-get install -y nodejsHow to lock into v16 (current LST)
# As a user with sudo
curl -fsSL | sudo -E bash -
sudo apt-get install -y nodejs
# As root
curl -fsSL | bash -
apt-get install -y nodejs