Nethence Newdoc Olddoc Lab Your IP BBDock  

Setting up NodeJS

Installation

On CentOS/RHEL,

curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
yum install nodejs gcc-c++ make
npm install mongodb

Ref. https://nodejs.org/en/download/package-manager/

Hello World

Eventually check that node is working fine,

cd ~/
mkdir nodejs/
cd nodejs/
cat > hello.js <<-EOF
var http = require("http");
http.createServer(function(request, response) {
        response.writeHead(200, {"Content-Type": "text/html"});
        response.end("Hello World!");
        }).listen(8080);
EOF
node hello.js
curl 127.0.0.1:8080

Home | GitHub | Donate