Node Version Manager
One flexible method to install Node.js is by using NVM (Node Version Manager). NVM lets you install and manage multiple versions of Node.js and their associated packages concurrently.
To install NVM on Ubuntu, navigate to the project’s GitHub page and copy the curl command from the README. This command downloads the latest installation script.
Before piping the downloaded script to bash, consider auditing it by removing the “| bash” part from the command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
The installation script will add NVM to your user account. To activate it, source your .bashrc file:
source ~/.bashrc
After installation, you can check the available Node.js versions with:
nvm list-remote
Example output:
... v22.8.0
v22.9.0
v22.10.0
v22.11.0 (LTS: Jod)
v22.12.0 (LTS: Jod)
v22.13.0 (LTS: Jod)
v22.13.1 (LTS: Jod)
-> v22.14.0 (LTS: Jod)
v22.15.0 (LTS: Jod)
v22.15.1 (LTS: Jod)
v22.16.0 (Latest LTS: Jod)
v23.0.0
v23.1.0
v23.2.0
v23.3.0
v23.4.0
v23.5.0
v23.6.0
v23.6.1
v23.7.0
v23.8.0
v23.9.0
v23.10.0
v23.11.0
v23.11.1
v24.0.0
v24.0.1
v24.0.2
v24.1.0
To install a specific version (for example, v22.14.0 which is another LTS release), run:
nvm install v22.14.0
After installation, you can view all installed Node.js versions using:
nvm list
Example output:
-> v22.14.0
default -> v22.14.0
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v22.14.0) (default)
stable -> 22.14 (-> v22.14.0) (default)
lts/* -> lts/jod (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.8 (-> N/A)
lts/iron -> v20.19.2 (-> N/A)
lts/jod -> v22.16.0 (-> N/A)