Installing the latest version of node using nvm:
Install the latest nvm through its Github repo:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
source ~/.bashrc
check the latest version of node and select it:
nvm list-remote
Out:
...
v20.15.0 (LTS: Iron)
v20.15.1 (LTS: Iron)
v20.16.0 (Latest LTS: Iron)
v21.0.0
v21.1.0
v21.2.0
v21.3.0
v21.4.0
v21.5.0
v21.6.0
v21.6.1
v21.6.2
v21.7.0
v21.7.1
v21.7.2
v21.7.3
v22.0.0
v22.1.0
v22.2.0
v22.3.0
v22.4.0
v22.4.1
v22.5.0
v22.5.1
v22.6.0
Install the desired version of node:
nvm install v20.16.0
Answer from Benyamin Jafari on askubuntu.comVideos
Installing the latest version of node using nvm:
Install the latest nvm through its Github repo:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
source ~/.bashrc
check the latest version of node and select it:
nvm list-remote
Out:
...
v20.15.0 (LTS: Iron)
v20.15.1 (LTS: Iron)
v20.16.0 (Latest LTS: Iron)
v21.0.0
v21.1.0
v21.2.0
v21.3.0
v21.4.0
v21.5.0
v21.6.0
v21.6.1
v21.6.2
v21.7.0
v21.7.1
v21.7.2
v21.7.3
v22.0.0
v22.1.0
v22.2.0
v22.3.0
v22.4.0
v22.4.1
v22.5.0
v22.5.1
v22.6.0
Install the desired version of node:
nvm install v20.16.0
INSTALL (Node Version Manager) be following command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashNow, reopen your terminal, or "
exit" command if you server ssh and reconnectGet packages by following command:
nvm install 20Veryfiy node by:
node -v# should print v20.16.0Finally check the npm:
npm -v # should print '10.8.1'
Gongrates! You have done!
First remove nodejs using,
sudo apt-get purge --auto-remove nodejs
Then after, if curl is not installed then run the below command
sudo apt-get install curl
Then after run the below 2 commands,
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
You can install the latest version from non Official Ubuntu repos.
First you can use a PPA (personal package archive) maintained by NodeSource.
curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
Change the permission to 755 or 764 and run the file
sudo bash nodesource_setup.sh
The PPA will be added to your configuration and now you can install the Node.js package...
sudo apt install nodejs
node -v
v16.10.0
the complete instructions for installing node from that distribution is two commands:
# install the source list, let apt-get install 'find' the nodejs package
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
# apt-get now knows about nodejs package
sudo apt-get install -y nodejs
you'll find that when you follow these instructions, the script will print how to install yarn, and you should do that, also several commands (for adding sources, keys, and then installing the packages from those lists).
Suggested method
I would suggest using the n library, because it doesn't require any OS modification, like so:
sudo npm i -g n
sudo n 20
use the following link to download https://nodejs.org/dist/v12.13.0/node-v12.13.0-x64.msi
I recommend using Node Version Manager:
NB: Node Version Manager (nvm) allows you to install multiple node versions and choose between them depending on which software you want to support; that is, manage multiple node versions.
Installing Node Version Manager
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Once you have Node Version Manager installed
- Confirm the available remote versions by running
nvm ls-remote - Run in your terminal
nvm install <version>for example,nvm install 18to install version 18 of Node - List installed versions with
nvm list - Run
nvm use 18to start using version 18 of Node - Note: you can be more explicit, for example:
nvm install 14.17.0
Install nodejs v20 on Debian and Ubuntu based distributions
step 1 : Download and import the Nodesource GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
step 2 : Create deb repository
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
optional: here we are installing nodejs v20 but if you want to install v18 change NODE_MAJOR=18 in above command. Similarly if you want to install nodejs v16 then change NODE_MAJOR=16.
step 3 : Run Update and Install
sudo apt-get update
sudo apt-get install nodejs -y
congratulations you just installed nodejs
To uninstall nodejs
sudo apt-get purge nodejs &&\
rm -r /etc/apt/sources.list.d/nodesource.list &&\
rm -r /etc/apt/keyrings/nodesource.gpg
Hk, Ubuntu 22 LTS when running apt-get install nodejs i get version 12 which Mesh installer fails on loads of dependencies needing to be v14 or newer. Cant find how to get a new version of Node on Ubuntu, the manual lists a command that i get output errors with.