• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to install Node.js in CentOS

{{postValue.id}}

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
{{postCtrl.cmtErrMsg}}

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

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 Jayce ?
What are the types of table used in IPtables

What are the various types of table used in IPtables and how to use that for my server security?

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.