Node.js is a free and server-side platform for JavaScript runtime environment set up on Chrome (V8) JavaScript Engine. The Node.js environment is developed to build back-end solutions and be famous for networking applications, full-stack, and front-end development.
The “npm (Node Package Manager)” is used to install multiple node packages and dependencies. Almost all the node packages are available on the world’s largest package manager registry.
We have multiple resources to download the Node.js and npm on Ubuntu 20.04, but why not select the effortless ways.
In this guide, we will see the two approaches for installation:
- Install Node.js and npm from Ubuntu Official Repository
- Install Node.js Using nvm
Let’s begin:
How to Install Node.js and npm from Ubuntu Official Repository
To download Node.js and npm from Ubuntu’s repository is a pretty straightforward and simplest way. What we need to do is, open the terminal and update all the package index of the Ubuntu system:
Run the following command to install the Node.js environment with all the necessary packages on Ubuntu machine:
Once done, verify if the installation has accomplished by checking its version:
Through the Ubuntu official repository, the installed node.js is the latest available package. It is not compulsory to go with it; if you want to install the specific one, then move towards the 2nd approach in this guide.
To install the npm library on the system is as simple as we have installed the node.js. Write the given command to initiate the installation process of the npm in the command line:
The Node.js and the npm library have been installed on the system from the Ubuntu official repository.
How to Install Node.js using nvm
In the above section, we have seen that through the Ubuntu repository, only the latest available package of Node.js can be installed. To get the specific version of Node.js on a system, download it through nvm that is the abbreviated form of “Node Version Manager”. As the name describes, it is the bash script consist of all node versions and allows the user to install and test any Node.js version as per requirement.
To get the download link, you can visit https://github.com/nvm-sh/nvm#installing-and-updating, or you can copy the mentioned curl command in the terminal:
You might face this issue, and to resolve this, install the curl command:
Now, run the above curl command of node.js again to begin nvm installation:
To source the bash file, run the given command:
Run the mentioned command to show the list of Node.js available versions:
Use the following syntax to install the version you want:
For instance, to install the node version “v10.24.1”, the command would be:
To check the list of all node versions installed on Ubuntu machine, the command is:
How to Uninstall Node.js from Ubuntu 20.04
If you want to uninstall the Node.js from the system, use the mentioned command:
Conclusion
This write-up shows how to install Node.js and npm on Ubuntu 20.04 using Ubuntu repository and nvm methods.
Node.js is an open-source networking and server-side platform used to build JavaScript runtime applications. The npm is a package manager for all the available versions of Node.js, while the nvm manager is used to download a specific version.