I have node version v14.21.2 in my linux system. I have applied following code for upgrading node version in terminal but its still showing older version-
sudo apt-get install nodejs
I have previously node version v14.21.2. after upgrading it still showing older version.
2
Answers
If you have v14.21.2 and want to install v16.15.0 then
To delete old version global packages
If you don’t have
nvm
thennvm install node
or LTS bynvm install --lts
nvm alias default x.y.z
nvm use version
nvm uninstall verison
When you execute the command:
You’re actually getting the default version of Node.js from Ubuntu’s repository of software sources.
Given that we don’t know your version of Ubuntu and therefore can’t be sure what version of Node you have installed when you run the command.
So you can try to update the software source via the command:
Or I would recommend using the NodeSource source repository
This command allows you to specify the Node.js repository you want to install and add it to the Ubuntu repository, and install it via apt