Install and Manage Node.js with NVM

| 19 Aug 2023

Installation Steps

Download and run the installation file:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash

Exit the terminal session then reopen a terminal so that the environment changes take effect. Then run:

nvm -v

to ensure NVM is installed correctly.

Using NVM

Install the latest Node version with:

nvm install node

Install a specific version with:

nvm install 16

or for a more specific version:

nvm install 14.4.5

List the installed versions with:

nvm ls

Switch to an installed version with:

nvm use 14

or for a more specific version:

nvm install 14.4.5

Find the current Node version with:

nvm current

Node Installation Error

If there is an error running the nvm install command similar to Warning: Failed to open the file, the installation file may need to be downloaded manually. Download the file from the link noted above this error message, then run the following, adjusting the version number to match the file downloaded.

cd ~/.nvm/.cache/bin/
mkdir node-v16.18.0-linux-x64
mv ~/Downloads/node-v16.18.0-linux-x64.tar.xz node-v16.18.0-linux-x64/
cd ~
nvm install 16

The rest of the install process should complete normally.