This tutorial will cover step by step methods “how to install node js in ubuntu 19.04″.
in case you need the latest Node.js and versions. If you are using Node.js for development purposes then your best option is to install Node.js using the NVM script.
Although this tutorial is written for Ubuntu the same instructions apply for any Ubuntu-based distribution, including Kubuntu, Linux Mint and Elementary OS.
- Check if node js installed already or not
- Prerequisites to install node js in Ubuntu
- The easiest method to Install node js in Ubuntu 20.04
- Install npm
- How to install the latest version of node js on Ubuntu 20.04
- Uninstall node js
- Video: How to install nodejs in Ubuntu 20.04
Important Command Tables
|nodejs -v||Check the installed nodejs version|
|sudo apt-get update||Update Ubuntu repository|
|sudo apt-get install nodejs||Install nodejs on Ubuntu/Debian|
|sudo apt-get install npm||Install npm on Ubuntu/Debian|
|sudo apt-get remove nodejs||Remove nodejs from Ubuntu/Debian|
|sudo apt-get purge nodejs||Remove Nodejs with its configuration files|
|sudo apt-get autoremove||Remove unused packages|
Check if node js installed already or not
vijay@Ubuntu-20:~$nodejs -v Command 'nodejs' not found, but can be installed with: sudo apt install nodejs vijay@Ubuntu-20:~$
Prerequisites to install node js in Ubuntu
There is not any specific requirement to install node js in Ubuntu 20.04, but one important thing you should keep in your mind that you have to with /root user to perform these tasks.
One more thing, Internet should be run on the machine, on which you want to install node.js.
The easiest method to Install node js in Ubuntu 20.04
If you need Node.js only for deploying Node.js applications then the easiest option is to install the Node.js packages using apt/apt-get from the Default Ubuntu repository or from the NodeSource repository.
Ubuntu consists latest and stable package of node.js on its repository. May be you not get latest version from repository but you will get stable version of node.js
You can use following code to install node js in Ubuntu 20.04
$apt-get install nodejs
vijay@Ubuntu-20:~$sudo apt-get install nodejs Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libc-ares2 libnode64 nodejs-doc Suggested packages: npm The following NEW packages will be installed: libc-ares2 libnode64 nodejs nodejs-doc 0 upgraded, 4 newly installed, 0 to remove and 32 not upgraded. Need to get 6,807 kB of archives. After this operation, 30.7 MB of additional disk space will be used. Do you want to continue? [Y/n]
vijay@Ubuntu-20:~$nodejs -v v10.19.0 vijay@Ubuntu-20:~$
Install on Ubuntu 20.04
stands for Node Package Manager, allow you to easily install new modules and packages required for Node.js
$sudo apt-get install
vijay@Ubuntu-20:~$sudo apt-get install npm
vijay@Ubuntu-20:~$npm -v 6.14.4 vijay@Ubuntu-20:~$
How to install latest version of node.js in Ubuntu 20.04
I installed node.js by using apt-get command, Latest and stable version on ubuntu repository is 10.x. I thought this is latest version, but i was wrong.
When I visited Github of node.js for the latest release, I found version is 12.x
Question: How can I install version of node.js on Ubuntu, if not installed by using sudo apt-get install nodejs command on Ubuntu 20.04.
So In this section I will cover install latest version on Ubuntu 20.04
First, curl should be installed on your system. If you don’t have curl installed then use following command to install curl.
$sudo apt-get update
$sudo apt-get install curl
vijay@Ubuntu-19:~$sudo apt-get install curl Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: curl 0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded. Need to get 166 kB of archives. After this operation, 410 kB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu disco/main amd64 curl amd64 7.64.0-2ubuntu1 [166 kB] Fetched 166 kB in 2s (79.5 kB/s) Selecting previously unselected package curl. (Reading database ... 143463 files and directories currently installed.) Preparing to unpack .../curl_7.64.0-2ubuntu1_amd64.deb ... Unpacking curl (7.64.0-2ubuntu1) ... Setting up curl (7.64.0-2ubuntu1) ... Processing triggers for man-db (2.8.5-2) ... vijay@Ubuntu-20:~$
Now you can install any version of node.js on Ubuntu system, It may be latest or old version.
Following instruction to install different packages on your system.
$sudo curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash –
$sudo apt-get install -y nodejs
vijay@Ubuntu-20:~$nodejs -v v12.2.0 vijay@Ubuntu-20:~$
Similar you can install any version whatever you want.
$sudo curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash –
$sudo apt-get install -y nodejs
$sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash –
$sudo apt-get install -y nodejs
Optional: install build tools
To compile and install native addons from npm you may also need to install build tools:
sudo on Ubuntu or run this as root on debian
$apt-get install -y build-essential
Uninstall node js in Ubuntu
You don’t have use of node.js anymore and don’t want in your Ubuntu system anymore.
Don’t worry, you can uninstall it by following a simple method. The instructions are below.
To remove use following command:
$sudo apt-get remove nodejs
This command will remove your installed package but retain the configuration files. These files will be used by nodejs if you will install again on the same system.
If you want to remove nodejs with its configuration files use the following command
$sudo apt-get purge nodejs
Feeling some light, after uninstalling the package. Do you know “there are some unused packages exist in your system, which was added automatically at the time of installation on node.js.
These packages are called dependencies? if you want to remove those unused packages, run following command.
How to install nodejs on Ubuntu Video tutorial in Hindi
As you can see, there are two methods as described to get up and running node.js on your Ubuntu 20.04. You can find out which method is better for you and go through it.
You can install/update/remove nodejs and from your system, whenever you want.
If you like this article please share, If you have any questions, write in the comment box. If you want to contact me through mail id firstname.lastname@example.org use it.