Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Latest version node.js yum repository is maintaining by its official . Use this tutorial to add repository and Latest to / 7/6 systems with the simple commands.

Step 1 – Add Node.js Yum Repository

First of all, You need to enable node.js yum repository in your system provided by the Node.js official website. You also need development tools to build native add-ons to be installed on your system.

For Latest Release:-

yum install -y gcc-c++ make
curl -sL | sudo -E bash -

For Stable Release:-

yum install -y gcc-c++ make
curl -sL | sudo -E bash -

Step 2 – Install Node.js on CentOS

After adding yum repository in your system lets install Node.js package. will also be installed with node.js. This will also install many other dependent packages on your system.

sudo yum install nodejs

Step 3 – Check Node.js and NPM Version

After installing node.js verify and check the installed version. You can find more details about current version on node.js official website.

node -v 


Also, check the version of npm.

npm -v 


Step 4 – Create Demo Web Server (Optional)

This is an optional step. If you want to test your node.js install. Let’s create a web server with “Welcome Node.js” text. Create a  demo_server.js

vim demo_server.js

and add the following content

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

Now start the web server using the command.

node --debug demo_server.js

debugger listening on port 5858
Server running at

Web server has been started on port 3001. Now access url in browser.

Print Friendly, PDF & Email



Bài viết liên quan