Install Node.js on CentOS AWS


 Steps to install Node.js on CentOS AWS in no time

You can also follow same steps to install Node.js for other OS such as Amazon Linux AMI and RedHat (rhel). Steps to install Node.js on CentOS AWS are as follows :

Step 1 : Install git 

sudo yum install git

Step 2 : Clone repository 

git clone

Step 3 : Execute the installation script 

cd  Nodejs-installation-AWS
sudo bash

Step 4 : Compile and install native addons from npm you may also need to install build tools:

sudo yum install  gcc-c++ make
or: sudo yum groupinstall 'Development Tools'

Step 5 : Install Nodejs

sudo yum install -y nodejs

Once done go ahead and check the version of node and npm with following commands:

node -v

npm -v

That’s it you’ve successfully installed Node.js on CentOS (AWS)

Deploying sample Node.js app using Hapi :

Step 1 : After following above steps of installation go ahead and make a directory 

mkdir hapiapp && cd hapiapp

Step 2 : Create a file index.js and copy paste following content in it

var Hapi = require('hapi');
var server = new Hapi.Server();

server.connection({port: 3000});

    method: 'GET',
    path: '/{yourname*}',
    handler: function(req, reply) {
        reply('Hello ' + req.params.yourname + '!')

server.start(function(){ // boots your server
    console.log('Now Visit: http://localhost:3000/YOURNAME')

module.exports = server;

Step 3 : Install Hapi

npm install hapi

Step 4 : Run the node server using following command

node .
Visit: http://serveripaddress:3000/YOURNAME (in your browser)

Note : Make sure you have opened port 3000 in AWS security groups.

If everything is configured properly you will see a message in brower, which means you’ve successfully installed a demo app on Node.js using Hapi

Thank you for reading!

If any queries feel free to comment or write at

Blogger & Assc Cloud Architect

Site Footer

%d bloggers like this: