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:

sudo apt install nodejs npm.

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:

ln -s /usr/bin/nodejs /usr/bin/node.

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:

node –versionnpm –version

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.

Similar Reads

What is Node.js?

Node.js is a runtime environment that operates separately from the browser. It utilizes Chrome’s V8 JavaScript engine, enabling users to efficiently use the JavaScript programming language—which they may already be familiar with—to create backend applications, even at a beginner level. Node.js is versatile and can be used effectively by both front-end and back-end programmers....

What is NPM?

NPM, or Node Package Manager, is more than just a package manager and software registry system. It allows developers to locate, create, and manage essential code packages. Currently, NPM hosts over 800,000 packages for various uses, including front-end development, robotics, and Android applications, facilitating smooth interfaces. Initially developed as a package manager application for Node.js, it was aptly named NPM....

Method 1: Using the Official Repository of the Ubuntu

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:...

Method 2: Via Using NodeSource Repository

We can also directly install node.js and npm using the official node source repository, for this, we follow the steps mentioned:...

Method 3: By Using NVM or Node Version Manager

The NVM is also an easy to use and installer for the node and it offers the flexibility for us to easily switch between different versions of node, let’s understand step by step how to install node.js and npm using NVM:...

Method 4: By Using Snap Installer

This is also another simple method where we use snap (third-party software) that acts as a play store for Ubuntu to provide installation of Ubuntu software, here are the steps:...

Also Read

Node.js Introduction NodeJS Tutorial Node JS NPM...

Conclusion

In conclusion, we learned how we can install the node.js and npm using four methods each method used in this article goes through its process to install the node.js and npm so if you are struggling to install node.js and npm then you can simply follow any of the method(s) to install the node.js and npm on your system in an easy way....