Node.js is a cross-platform JavaScript run-time atmosphere that permits server-side execution of JavaScript code. Node.js is mostly used on the back-side off the application, but it is also widespread as a full-stack and front-end solution.
npm, short for Node Package Manager is the defaulting package manager for Node and the world’s leading software repository for the distributing of open-source Node.js packages.
This lecture walks you conclude the steps that how to install Node.js and NPM on a CentOS 7 server. We will appearance you 2 different methods of installing Nodejs and npm.
In the first portion of this article i will install Node.js and npm using the yum package manager from the NodeSource repository and in the second portionwe will explain you how to install Node.js and npm using the nvm script.
http://www.linuxpcfix.com/install-hadoop-single-node-centosrhel/
Install Nodejs and NPM from the EPEL Repository
Before installing node we need to install EPEL repository so execute the below command to install EPEL repository .
Now you have crawl to the Extra Packages for Enterprise Linux (EPEL) repository, you can install Node.js by using yum commands:
[root@linuxpcfix]#node –version
v0.10.30
Install Node.js and npm from the NodeSource repository
The current version of Node.js is version 10.x. If you want to install other version just change setup_10.x with setup_x.x in the command. For example if you want to install version 8 then add setup_8.x. In this tutorial I am going to install verion 10.
Execute the below curl command to add the NodeSource yum repository to your server:
Install Node.js and npm
The NodeSource repository has enabled now you can install Node.js and npm by typing:
When you prompted to fetch the repository GPG key, type y and hit Enter.
Verify the Node.js and npm Installation
To check status that the installation is successful or not, perform the following commands which will show the Node.js and npm versions.
Print Node.js version:
v10.13.0
Print npm version:
[root@linuxpcfix]#npm –version
Install nodejs using NVM
NVM (Node Version Manager) is a bash script used to accomplish multiple active Node.js versions. NVM allows us to install and uninstall any particular Node.js version which means we can install any number of Nodejs versions as per requirement.
To install Node.js and npm using NVM on your CentOS server, follow below these steps:
Install NVM (Node Version Manager)
To download the nvm installation script perform the below command:
The command script will clone the nvm repository from Github to ~/.nvm and add the script Path to your Bash or ZSH profile.
To check status that nvm was properly installed type:
0.33.11
Finally run the below command to install node using NVM.
Downloading and installing node v10.0.0…
Downloading https://nodejs.org/dist/v10.0.0/node-v10.0.0-linux-x64.tar.xz…
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.0.0 (npm v6.4.1)
Creating default alias: default -> node (-> v10.0.0)
Verify the Node.js version, by typing:
v10.1.0
Install multiple Node version.
[root@linuxpcfix]#nvm install –lts
Once 8.12.0 and LTS version are installed to list all installed Node.js instances type:
-> v8.12.0 # ACTIVE VERSION
v10.13.0
v11.0.0
default -> node (-> v10.13.0) # DEFAULT VERSION
node -> stable (->v10.13.0) (default)
stable -> 11.0 (->v10.13.0) (default)
iojs -> N/A (default)
lts/* -> lts/dubnium (-> v10.13.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.4 (-> N/A)
lts/carbon -> v8.12.0
lts/dubnium -> v10.13.0
The output showing us that the entry with an arrow on the left (-> v8.12.0), is the current version used in the current shell session and the default version is set to v10.13.0. And default version is the current version that will be use when opening new shells.
To Install Nodejs and NPM on Ubuntu.
Nodejs and NPM packages are available on the Ubuntu distribution repo. In this arctible we are using Ubuntu 18.04 version.
[root@linuxpcfix]# apt-get install nodejs npm
[root@linuxpcfix]# nodejs –version
v8.10.0
To change the current active version you can execute the following command:
Now using node v10.13.0 (npm v6.4.1)
To change the default Node.js version type:
default -> 10.13.0 (-> v10.13.0)
Thanks reading this tutorial, In this tutorial we have described multiple method of Node.js installation on linux server.