To install Node.js binary version on Ubuntu-based systems, there are multiple options available. Here are step-by-step instructions for installing nodeJS on Ubuntu using different methods:
Option 1: Installing Node.js from the Ubuntu repositories using apt
Update your local package index with the command:
sudo apt update
Install Node.js and npm by running the command:
sudo apt install nodejs
Check if Node.js was installed correctly by running the following command. It will tell the version of NodeJS installed if the installation was successful.
node --version
Note: The version of Node.js included in the Ubuntu repositories may not be the latest version available. If you need a different version, consider using the second method
Option 2: Installing Node.js using the Node Version Manager (nvm)
Visit the following website: https://github.com/nodesource/distributions
Select the version which you want to install among the various versions given. We will be sticking to the LTS version as an example
Install the LTS version (currently it is 18.16.0) by running the following command in the terminal:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\ sudo apt-get install -y nodejs