How to use the Official Repository of the Ubuntu In NodeJS
The node.js and npm are available in the official repository of Ubuntu, so using the official repository becomes the easiest method to install both node.js and npm in Ubuntu, for this you will have to follow the below steps:
Step 1: Open Terminal Window
First, go to the start menu of the Ubuntu system and open the terminal, you can also use the shortcut key (CTRL+ALT+T) to open the terminal.
Step 2: Run the Command
Now you simply need to run the following command that will install npm and node.js using the apt in Ubuntu:
sudo apt install nodejs npm
This will give you the following output and install npm and node.js for you:
Step 3: Create a Symbolic Link
Now you will have to create a symbolic link, the reason for this is that node js uses binary path /usr/bin/node but our installed path is /user/bin/nodejs so we will get an error as “No path or directory found” if we don’t create a symbolic link.
To create the symbolic link, run the following command:
ln -s /usr/bin/nodejs /usr/bin/node
This will give the following output if the link is already created by the repository, otherwise, it will create the link:
Step 4: Check if node.js and npm is installed or not
This is the last step where we check whether the node.js and npm are installed or not, for this run the following command:
node --version
npm --version
If it shows output similar to the image below (version may differ) then npm and node.js are installed successfully:
How to Install Node.js and npm on Ubuntu?
As you may be aware already, npm and node.js are very powerful web development tools that are used for full-stack development purposes. It is straightforward if you ever want to install npm or node.js in the Windows operating system. In this article, we will cover some effective methods that you can use to install npm as well as node.js in your required distribution.