• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to install Node.js in CentOS

479

To install Node.js in CentOS

Node.js is a JavaScript-based platform used to create scalable network applications in Linux systems. It enables the users to develop high-performance server-side applications in an efficient manner. Developers can use this utility as both the front-end and the back-end. Installation of Node.js in CentOS is explained in this article.

Installation of Nodejs

First add the node.js repository with the following command.

[root@linuxhelp1 Desktop]# curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -

## Installing the NodeSource Node.js 6.x repo...

## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming " el7-x86_64"  is supported...

+ curl -sLf -o /dev/null ' https://rpm.nodesource.com/pub_6.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm' 
.
.
.
+ rpm -qa ' node|npm'  | grep -v nodesource

## Run `yum install -y nodejs` (as root) to install Node.js 6.x and npm.
## You may also need development tools to build native addons:
##   `yum install -y gcc-c++ make`


Then run the below command to install the dependency addons.

[root@linuxhelp1 Desktop]# yum install -y gcc-c++ make
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
(1/2): extras/7/x86_64/primary_db                          | 160 kB   01:19     
(2/2): updates/7/x86_64/primary_db                         | 7.1 MB   01:28     
Determining fastest mirrors
 * base: centos.excellmedia.net
 * extras: mirrors.viethosting.vn
 * updates: mirrors.viethosting.vn
Resolving Dependencies
-->  Running transaction check
--->  Package gcc-c++.x86_64 0:4.8.5-4.el7 will be installed
-->  Processing Dependency: libstdc++-devel = 4.8.5-4.el7 for package: gcc-c++-4.8.5-4.el7.x86_64
.
.
.
Installed:
  gcc-c++.x86_64 0:4.8.5-4.el7                                                  

Dependency Installed:
  libstdc++-devel.x86_64 0:4.8.5-4.el7                                          

Dependency Updated:
  libstdc++.x86_64 0:4.8.5-4.el7                                                

Complete!


Now its time to install the node.js with the following command.

[root@linuxhelp1 Desktop]# yum install nodejs -y
Loaded plugins: fastestmirror, langpacks
nodesource                                               | 2.5 kB     00:00     
nodesource/x86_64/primary_db                               |  18 kB   00:01     
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: mirrors.viethosting.vn
 * updates: mirrors.viethosting.vn
Resolving Dependencies
-->  Running transaction check
--->  Package nodejs.x86_64 1:6.4.0-1nodesource.el7.centos will be installed
-->  Finished Dependency Resolution
.
.
.
Warning: RPMDB altered outside of yum.
  Installing : 1:nodejs-6.4.0-1nodesource.el7.centos.x86_64                 1/1 
  Verifying  : 1:nodejs-6.4.0-1nodesource.el7.centos.x86_64                 1/1 

Installed:
  nodejs.x86_64 1:6.4.0-1nodesource.el7.centos                                  

Complete!


If you want to check the version of node and npm, just run the below command.

[root@linuxhelp1 Desktop]# node -v
v6.4.0
[root@linuxhelp1 Desktop]# npm -v
3.10.3


Now create a demo web server on nodejs with the name of demo_server.js and paste the following code inside the file.

var http = require(' http' ) 
http.createServer(function (req, res) {
  res.writeHead(200, {' Content-Type' : ' text/plain' }) 
  res.end(' Welcome To Linuxhelp.com’ ) 
}).listen(3001, " 127.0.0.1" ) 
console.log(' Server running at http://127.0.0.1:3001/' ) 


Run the below command to start the nodejs web server.

[root@linuxhelp1 Desktop]# node --debug demo_server.js
Debugger listening on [::]:5858
Server running at http://127.0.0.1:3001/

Finally open the web browser and type the link http://127.0.0.1:3001/ to see the output of the file.

web_browser

Tags:
mason
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How can we install multiple node versions (more than one node version)?

A

With the help of nvm setup install the multiple node version

Q

What are the essential properties of node.js?

A

Node.js is a JavaScript-based platform used to create scalable network applications in Linux systems. It enables the users to develop high-performance server-side applications in an efficient

Q

what are all the dependent package to install the nodejs?

A

run the below command to install the dependency addons
# yum install -y gcc-c++ make

Q

how to install node.js on centos?

A

you can install the node.js by following command
# yum install nodejs -y

Q

which command to check the version of node and npm in terminal?

A

to check the version of node and npm just refer the below command
# node -v
# npm -v

Related Tutorials in How to install Node.js in CentOS

Related Tutorials in How to install Node.js in CentOS

How to install TLDR - An alternate to Man pages
How to install TLDR - An alternate to Man pages
Jul 28, 2016
How to install Node.js 10 on centos7
How to install Node.js 10 on centos7
Dec 20, 2018
How to install Nodejs 8 on Ubuntu 18.04
How to install Nodejs 8 on Ubuntu 18.04
Dec 6, 2018
How to Install Node.js 12 on Ubuntu 19.04
How to Install Node.js 12 on Ubuntu 19.04
Jun 19, 2019
How To Install nodejs 10.16 On CentOS 7.6
How To Install nodejs 10.16 On CentOS 7.6
Jul 16, 2019
How to Install, Update and Manage Node.js with n Command on Ubuntu 19.04
How to Install, Update and Manage Node.js with n Command on Ubuntu 19.04
Jun 28, 2019
How to use Wetty tool in browser - Accessing server terminal
How to use Wetty tool in browser - Accessing server terminal
Jul 23, 2016
How to install Webstrom in Ubuntu
How to install Webstrom in Ubuntu
Jul 16, 2016

Related Forums in How to install Node.js in CentOS

Related Forums in How to install Node.js in CentOS

Node.js
aiden class=
How To solve the issue during the installation of nodejs version 10 and 11 on ubuntu 18.04
Nov 15, 2018
Node.js
lucas class=
Npm ERR! Cannot read property 'match' of undefined
Sep 3, 2019
CentOS
jackson class=
2:nodejs-10.15.3-1nodesource.x86_64: [Errno 256] No more mirrors to try. On CentOS 7.6
May 28, 2019

Related News in How to install Node.js in CentOS

Related News in How to install Node.js in CentOS

Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Elijah ?
Remote Desktop Connection Has Stopped Working

When accessing my remote machine server using remote desktop on a windows machine I am getting this error

forum (1)

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.