// Enabling NodeSource Repository
// replace %V% with desired major version
curl -sL https://deb.nodesource.com/setup_%V%.x | sudo bash -
// Install using apt-get
sudo apt-get install -y nodejs
// check installed node version
node --version
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
//Installing Node Using the Node Version Manager
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm ls-remote
//Output
..
v14.18.2 (Latest LTS: Fermium)
v15.0.0
v15.0.1
v15.1.0
v15.2.0
v15.2.1 .....
nvm install v18.3.0
//output
v18.3.0
more info on ---> https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04