You might want to install Node.js for various reasons, and depending on whether you would like to have the latest version of the version available in your Ubuntu repository, there are two way to get the package.
Let’s start with the simple one:
Open a terminal and write the following (don’t copy the dollar sign):
$ sudo apt-get update
Now, get node.js
$ sudo apt install nodejs
You might also want to install the npm (Nodes Package Manager)
$ sudo apt install npm
You are now able to check the versions and see if packages work:
$ nodejs -v
$ npm -v
Now to the (slightly) more complicated installation (in case you would like the latest node.js version):
To be able to install more recent versions of software on Ubuntu (stable) you can make use of so-called PPA’s (Personal Package Archives) which are collections of software not included in the Ubuntu repository by default. So if you are generally interested in more recent software that the repository doesn’t offer, it is alway worthwhile looking for any PPA.
You might want to check this too:
https://help.ubuntu.com/stable/ubuntu-help/addremove-ppa.html.en
Now, back to our installation of Node.js:
Return to your home directory
$ cd
Get the installation script using CURL (if you don’t have the program yet, you can get it from the repository with “sudo apt install curl”).
I am using here “setup_10.x” , but check first on https://nodejs.org/en/ for the current version and replace
$ curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
Now run this script with root privileges
$ sudo bash nodesource_setup.sh
Voilà! The PPA has now updated your repository with the newest version of Node.js. You can install:
$ sudo apt install nodejs
The PPA package of nodejs should already have the npm with it.
You can check the versions:
$ nodejs -v
$ npm -v
Leave a Reply