I am new to js and wanted to install nodejs LTS version and npm on ubuntu 21.10. So, I followed the nodesources repository install instructions and it had stated to use the install script for LTS and it worked fine as I followed the same instructions mentioned in it.

But, after installation of the nodejs package, when I try to check the node -v: it shows as 12.x.x, while the latest LTS version for nodejs is 16.x.x. I did not understand why this is happening and what is the solution for this?

P.S: I have mentioned the commands that I had used for installation of nodejs LTS 16.x.x, and the site link is this: https://github.com/nodesource/distributions/blob/master/README.md


Node.js LTS (v16.x):

# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

Please note: I have not installed the optional build tools yet and not the npm as well. I'm confused on what to do now...

1 Answer 1


The first command there adds new repositories which apt-get will use when you request nodejs to be installed. I guess that the first command failed for whatever reason (perhaps you didn't copy the entire line including the -, perhaps you typed the password wrong). As a result, the second command gave you the ubuntu-system-default version of node.

My recommendation to you now is to install and use nvm to install whatever node version you want. You can follow the installation instructions here https://github.com/nvm-sh/nvm. With nvm, you can install and switch between node installations that are user-local, for example:

$ nvm install 17
$ node -v
$ which node

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.