How to Install Node.js and NPM on Ubuntu 18.04

Advertisement

Responsive Ads Here

How to Install Node.js and NPM on Ubuntu 18.04

Tuesday, October 8, 2019

How to Install Node.js and NPM on Ubuntu 18.04 - Hallo Dear, elisa-head.blogspot.com, This article that you read this time with the title How to Install Node.js and NPM on Ubuntu 18.04, We have prepared this article well for you to read and retrieve the information in it. hopefully the contents of this article ubuntu, this article VPS, we write can be understood by you. Alright, happy reading.

Title : How to Install Node.js and NPM on Ubuntu 18.04
link : How to Install Node.js and NPM on Ubuntu 18.04


How to Install Node.js and NPM on Ubuntu 18.04

[ad_1]

You are using Linux Ubuntu and want to install Node.js and NPM? Take it easy because the way is quite easy. There are at least three ways to install Node.js and NPM, namely using your own PPA, using a repository, and utilizing NVM services through the Terminal. Everything we will discuss in this article.


What is Node.js?


Node.js is a Javascript platform that runs on clients and servers. This platform is similar to PHP in the server section. It's just that Node.js uses Javascript as a whole.


Node.js allows developers to execute and build lines of Javascript programs in the server environment. So through Node.js, JavaScript not only runs in the browser, but also on the server.


The software development process will be easier thanks to Node.js. You don't need to learn other programming languages ​​and also be more consistent in designing programs.


What is NPM?


NPM is a kind of software package manager. So when you want to install an application just use a few commands. This command is usually run on the Terminal on Linux or the Command Line on Windows.


So when you use NPN you don't need to download the file first. You only need to run one or two commands and the application will automatically be installed.


Have you ever used a Linux operating system? The function of NPM is almost the same as APT on Ubuntu or Pacman on Arch. Well, NPM is specifically used to take some resources in the process of developing software or applications by developers.


For example only when you need the Bootstrap framework. You just need to type it "$ Sudo npm install bootstrap" in the Terminal. NPM will automatically install Bootstrap into the project.


How to Install Node.js and NPM on Ubuntu 18.04


The installation process of NPM and Node.js on Linux (especially Ubuntu) is very easy. In this article, we will discuss at least three ways you can install Node.js on Ubuntu.


In addition to Ubuntu, Node.js and NPM can be on all Linux platforms, such as Fedora, CentOS, Lubuntu, and so on.


Three ways to install Node.js and NPM on Ubuntu:


  1. Use the latest Ubuntu version and add your own PPA.
  2. Via the official Ubuntu repository.
  3. Using NVM (Node.js Version Manager).

1 How to Install Node.js and NPM Using Your Own PPA


How to install NPM is quite difficult because you have to execute the program installation directly through the Terminal. However, if you want to get the latest version of NPN and Node.js it would be better to use this method.


The first thing you need to prepare is to add PPA (Personal Package Archive). The trick, download the program executable file to nodesource.com.


Go to the home directory (home folder on Linux).


$ cd ~

Then download the PPA installation script. You can use curl to download the file. Make sure you are using the latest version of PPA available.


$ curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh

If the download process is complete, you can immediately compile the downloaded file. The trick is to use sudo and orders bash.


$ sudo bash nodesource_setup.sh

When the compilation process is complete, you can immediately continue the installation process using the command ‘Apt’. In this process, NPM will automatically be installed when Node.js is installed using PPA.


$ sudo apt install nodejs

2 How to Install Node.js and NPM Through Repositories on Linux


Want an easier way? You can use the repository in Linux. This method is relatively easier compared to other methods. So it is suitable for those of you who are not too familiar with Node.js.


The first thing you need to do is update the repository. If so, you can immediately do the installation process using the command below.


$ sudo apt update

$ sudo apt install nodejs

When the installation process is complete, you can check the version of Node.js using "$ nodejs -v".


This installation process does not include the NPM program, so if the version of Node.js is not what you want, you will need to install some JavaScript modules and packages using NPM.


So the next step is to install NPM using the command below.


$ sudo apt install npm

You can check the NPM version using the command "$ Npm -v".


3 How to Install Node.js Using NVM (Node.js Version Manager)


The last way you can use is to use Node.js Version Manager. If you want to use more than one version of Node.js, you need to use this method.


NVM allows you to install multiple versions of Node.js on one system.


In addition, you can also set the default Node.js version of one of the versions already installed in the system.


You need several packages to be able to run NVM and install Node.js correctly, i.e. build-essential and libssl-dev.


$ sudo apt update

$ sudo apt install build-essential libssl-dev

Then, if the package is installed, you need to retrieve the NVM installation file from Creationix by using curl as the command below.


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

Or, you can use wget via the command below.


$ sudo wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | sudo bash

The above command will download the NVM installation file and will automatically install it directly.


For NVm to work, you need to restart Terminal.


Or, if you want to use it directly please run the following command in Terminal.


$ source ~/.bashrc

At this point you already have NVM installed. Now, the difference between NVM and the other way is that it allows you to choose the version of Node.js.


First, you can check the current active version using the following command.


$ nvm ls-remote

The above command will bring up the Node.js version information that you can use.


Examples of the results are as shown below.


The above version is not installed, so you need to install it first.


How to install Node.js is very easy. You just have to point the version you want to use. For example if you want to install version 6.9.0:


$ nvm install 6.9.0

Not just one version, you can even use two versions of Node.js using NVM. The way to change the version number with the version you want.


If you have finished selecting and installing the version of Node.js that you need, you can see all the installed versions using the command ‘Ls’.


$ nvm ls

Meanwhile, if you want to change the default version of Node.js used by the system, use the option ‘Use’ followed by the designated version.


For example like the command below.


$ nvm use 7.7.3

Conclusion


The process of installing Node.js and NPM on Linux is quite diverse. You can use the repositories available in the operating system. You can also use NVM or use your own PPA added to Linux.


Of the three ways described above, the most recommended way is to use a direct repository because you don't need to do many things. Just run the update and install commands in Terminal then Node.js and NPM are installed automatically.


That was a brief guide on how to install NPM and Node.js on Ubuntu. If you still have questions, don't hesitate to add them through the comments column below. Please subscribe to get information related to online business, digital marketing, and technology from us.








[ad_2]


Thus the article How to Install Node.js and NPM on Ubuntu 18.04

So this article, How to Install Node.js and NPM on Ubuntu 18.04 hopefully can benefit you all. ok, see you in another article post.

You are now reading the article How to Install Node.js and NPM on Ubuntu 18.04 with the link address https://elisa-head.blogspot.com/2019/10/how-to-install-nodejs-and-npm-on-ubuntu_8.html