Recommended Read: Introduction to Bash Scripting Tutorial
In order to install NodeJs on Ubuntu, we must install it from nodesource. This will also install NPM on Ubuntu. NPM is the default package manager for the nodejs. NPM maintains the largest repository of packages for NodeJS.
Install NodeJS on Ubuntu/ Install NPM on Ubuntu
As mentioned above, we need to add the nodesource repository to the system first. To add the repository, use the following command,
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash –
This will install the version with LTS support but if you need to install the latest nodejs version, then use the following command,
$ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash –
NOTE: If ‘curl’ is not installed on the system, install it using the following command,
$ sudo apt-get install curl
Once the repository has been added, we can install nodejs on Ubuntu system with the following command,
$ sudo apt-get update
$ sudo apt-get install nodejs
As mentioned above also, this command will also install NPM on Ubuntu systems. Now we can confirm the installed versions for both NodeJS & NPM with the following commands,
$ npm -v
$ node -v
That’s it, this was our tutorial on how to install NodeJS on Ubuntu (& also npm on Ubuntu systems). We can now use the installed nodejs to create our applications. In our future tutorial, we will discuss how to install & maintain multiple versions of NodeJs on a single system using the NVM aka Node Version Manager. For this tutorial, you can leave your comments or questions using the comment box below.