Search at Knowledgebase
How to install NodeJs on Ubuntu 18.04


Node.js is an open source framework for the execution of the server-side Javascript code. Its efficiency is guaranteed by the Javascript V8 engine created by Google. In this guide you will be shown how to install Node.js on Ubuntu 18.04 with different methods.
First, connect to your server via an SSH connection. If you haven’t done so yet, following our guide is recommended to connect securely with SSH. In case of a local server, go to the next step and open the terminal of your server.

Installing Node.js

A more recent version of Node.js can also be installed from the NodeSource repository. In this case, download the automatic script to add the NodeSource repository to your configuration.
Use curl to download the script. In this case, download the script related to version 10 of Node.js:

$ curl -sL -o

Then run the newly downloaded script:

$ sudo bash

At this point, the NodeSource repository has already been added. Proceed with the installation of Node.js:

$ sudo apt install nodejs

Then verify the successful installation of Node.js using the command:

$ nodejs -v

If the installation was successful, the installed version will be displayed on the screen.
Also, check if the installation of NPM was successful by typing:

$ npm -v

As before, if the NPM version appears on the screen, the installation was successful.

Installing Node.js through NVM

Another way to install Node.js is by using NVM or the Node.js Version Manager. NVM allows you to install and manage multiple versions of Node.js on the same system.
To install NVM, download its installation script from the official project page on GitHub. So let’s proceed with the download via curl:

curl -o- | bash

Then, run the newly downloaded script:

$ bash

To complete the installation of NVM, login again or reload the .profile file in this way:

$ source ~/.profile

The installation is now completed.
To retrieve the list of the available versions for the installation, type the following command:

$ nvm ls-remote

To install node.js, all you need to do is choose the version you prefer and run the command:

$ nvm install 10.0.0

or 14.7.0, 16.3.0, 12.22.1, etc
by replacing 10.0.0 with the version number you prefer.
To use the newly downloaded version, use the nvm use command to select it, as follows:

$ nvm use 10.0.0

At this point, check if the current version of Node.js matches the one just selected:

$ node -v

Removing Node.js via apt

Node.js can be easily removed by using apt’s remove command, as follows:

$ sudo apt remove nodejs

While remove the associated configuration files, use the purge command:

$ sudo apt purge nodejs

Finally, remove all the packages installed automatically by Node.js.

Remove Node.js via NVM

To remove Node.js via NVM, use the corresponding ‘uninstal’l command followed by the version number of Node.js you want to uninstall:

$ nvm uninstall 

N.B. If the version you want to uninstall is the currently active one, disable it before uninstalling:

$ nvm deactivate
Your FREE Trial Starts Here!
Contact our Team for Application of Dedicated Server Service!
Register as a Member to Enjoy Exclusive Benefits Now!
Your FREE Trial Starts here!
Contact our Team for Application of Dedicated Server Service!
Register as a Member to Enjoy Exclusive Benefits Now!
Telegram Skype