Sunday July 10th, 2016


Install node.js on CentOS7

In this tutorial, we will install node.js on centOS7. Putting it in simple sentence, node.js is a Javascript platform for a server side programming. Node.js runs on the google javascript engine V8 which is written in C++. Just a little introduction on node.js, node.js is based on an event-driven, non blocking I/O model which basically means it uses the event-loops through Javascript's callback to implement the non blocking I/O. In some of my use cases, I've installed node.js to run some node codes or use npm (Package manager) to install some node modules written by other developer from the node.js community.


Let's install node from the source which is one way among others to install node.js. We will obtain the source code and compile it ourself.

Install node.js from source

In this section, we will install node for a given user (I will use kalilou as my user)

Make to be on your home folder

$ cd /home/kalilou

Get node source code

$ wget http://nodejs.org/dist/v"version"/node-v"version"-linux-x64.tar.gz

Unpack the tar.gz file

$ sudo tar -xzf /home/kalilou/node-v"version"-linux-x64.tar.gz

Create symbolic links for node.js executables mainly node and npm

$ cd /usr/bin
$ ln -sf /home/kalilou/node-v"version"-linux-x64/bin/node node
$ ln -sf /home/kalilou/node-v"version"-linux-x64/bin/npm npm

Now make sure node and npm are properly linked

$ cd /usr/bin
$ ls -l npm node 
$ lrwxrwxrwx. 1 root root 43 Jul 15:32 node -> /home/kalilou/node-v"version"-linux-x64/bin/node
$ lrwxrwxrwx. 1 root root 43 Jul 15:32 npm -> /home/kalilou/node-v"version"-linux-x64/bin/npm
© 2020 Revolight AB