Step 1. Press Ctrl+Alt+T to open Terminal.
Step 2. Check whether Node.js is installed on your machine by writing the following command:
node -v
Press Enter.
If you see any version being returned to you, it means that Node.js is installed on your machine, and you can skip steps 3 and 4.
If you see the message ‘Command 'node' not found, but can be installed with: sudo apt install nodejs’, which means that Node.js is not installed on your computer, close your Terminal and proceed to the next step.
Step 3. Run the following command to add Node.js-maintained repositories to your Linux package source list by first downloading the scripts from deb.nodesource.com and then running them:
sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
After the scripts are downloaded and run successfully, you will see something like this in your Terminal:
Step 4. Run the command given below in your Terminal to install Node.js on your machine:
sudo apt-get install -y nodejs
After Node.js has been installed on your machine, you will see something like this in your Terminal:
In order to verify that it has been correctly installed, open Terminal again and go back to step 2. If you see a version of Node.js being returned to you, it means that you have successfully installed its required version on your machine. However, if you still cannot see the version returned to you, you will need to uninstall (if required) and then re-install Node as explained above.
Happy coding!