18 C
Jaipur
Saturday, October 31, 2020

How to Install Node.js and npm on Ubuntu 20.04 – Linux Hint

Must read

Here’s the first IR night-vision rugged smartphone – shame about the screen resolution

Doogee S96 Pro - $239.99 pre-order at Aliexpress(£191.06/AU$431.93)The latest rugged smartphone from Doogee is now available to pre-order. Its main selling point is a...

Facebook Taken Down Number of Political ads due to Technical Flaws

Facebook on Thursday acknowledged that a technical error in its systems caused a variety of ads from both political parties to be improperly paused....

This is the cheapest 4K laptop right now, by a mile

Chuwi AeroBook Plus 4K laptop - $559.99 at BanggoodThis laptop from little-known manufacturer Chuwi is the most affordable 4K machine on the market. It...

Node.js is a runtime environment that comes with all the requisites to properly execute JavaScript files on your system. It is built on Chrome’s V8 JavaScript engine and uses the non-blocking I/O model. Npm is a package of Node.js and is a collection of almost all open-source libraries on the internet.

This article shows you how to get Node.js up and running on your Ubuntu 20.04 system using a non-root user account with sudo privileges.

There are two installation methods that we will look at:

  • Installing Node.js from Ubuntu’s official repository
  • Installing Node.js with nvm

Method 1: Installing Node.js from Ubuntu’s Official Repository

Installing Node.js with an apt package manager from Ubuntu’s official repository is fairly straightforward. First, update your package listing before running the installation command by entering the following:

$ sudo apt install nodejs

Verify the install by checking the version of Node.js you have downloaded:

The process shown above should download the latest package available in Ubuntu’s software repository. To download a specific version, try out one of the other methods in this tutorial.

You can install npm just like we installed Node.js with the apt repository. Enter the following command to commence installation of npm:

You have now installed npm and Node.js on your system. You can now start using node.js and the npm library to add functionalities to the software on your system.

Method 2: Using nvm to Install Node.js

If you want to download a specific version of Node, or if you just want more customizability in the installation, using nvm in the process can do this for you. Nvm stands for Node Version Manager and is a tool that lets you administer several side-by-side and active Node. js versions on your system.

First, copy the curl command from the readme file on the GitHub page for nvm:

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Paste it on the command terminal and run it to install the nvm. Then, run the following command to source your bash file.

To see what versions of Node are available to download, enter the following command:

Then, add whichever version you want to download in the following command syntax:

$ nvm install v(version number)

For example, to download v14.9.0, you would write the command as follows:

You have now successfully downloaded and installed Node.js v14.9.0 onto your system. You can download multiple different versions with nvm without the versions interrupting each other. You can even download and install long-term support versions of Node with nvm, such as Erbium or Dubnium. For example, the following command installs the latest Erbium version:

You can see all the versions of Node installed on your system by entering the following:

Use the following command to enter a different version of Node:

Nvm is a great tool to use because it brings together many options for efficient management of the Node.js software.

Wrapping Up

This tutorial looked at two different ways to install Node.js on an Ubuntu 20.04 server: by using nvm, and by directly requesting the program from the standard Ubuntu repository. If you are looking to install the latest version as quickly as possible, you should go with the first method. Otherwise, if you want more flexibility with your install, you can choose either of the two methods.

Check out Nodeproject’s official homepage to learn more about how to use Node on your Ubuntu 20.04 system.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Here’s the first IR night-vision rugged smartphone – shame about the screen resolution

Doogee S96 Pro - $239.99 pre-order at Aliexpress(£191.06/AU$431.93)The latest rugged smartphone from Doogee is now available to pre-order. Its main selling point is a...

Facebook Taken Down Number of Political ads due to Technical Flaws

Facebook on Thursday acknowledged that a technical error in its systems caused a variety of ads from both political parties to be improperly paused....

This is the cheapest 4K laptop right now, by a mile

Chuwi AeroBook Plus 4K laptop - $559.99 at BanggoodThis laptop from little-known manufacturer Chuwi is the most affordable 4K machine on the market. It...

How to Setup Raspberry Pi Bluetooth – Linux Hint

Bluetooth is a very popular communication protocol for short-distance wireless communication. There are many Bluetooth devices such as keyboards, mouses, headphones, speakers, etc. that...