Videos
Is it possible to install a specific version of NVM?
Can I use NVM on other operating systems besides Ubuntu?
What is NVM?
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
It looks like it's related to installing wget or curl with snap on Ubuntu:
https://github.com/nvm-sh/nvm/issues/2504
Here's what fixed it for me:
sudo snap remove curl
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install node
uninstalling snap curl and installing apt install resolved this for me as well,
sudo snap remove curl
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install node