Ubuntu Node Setup

Update server and install npm

sudo apt update && apt upgrade -y
sudo apt install npm

Installing NPM will also install node but it will not be the latest version! To resolve this issue install node version manager, then install latest stable node version, and switch to it.

Installing NPM will also install node but it will not be the latest version! To resolve this issue install node version manager, then install latest stable node version, and switch to it.

Node Version Manager

Install node version manager, then install latest stable node version, and switch to it.

# install node version manager
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Once the installation is complete, you may need to close and reopen your terminal or run source ~/.bashrc to make NVM available in your current terminal session.

Switching Node Versions

# install version
nvm install v18.17.1
# switch to latest version
nvm use v18.17.1

When the node RELP is open, press Ctrl + C to exit.

Note: the version will not change until you log out of the console and log back in.