To install node.js we will need the following:
Once all is ready we can now start install node.js on our server.
NVM or Node Version Manager is a piece of software that allows you to install and maintain many different independent versions of node.js and their associated node packages.
before we can install node.js on our machine we need to download and install NVM from GitHub. We can do this by the command.
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
This will install nvm version 0.13.1 but we will need to use first our bash_profile to use nvm.
Then we run nvm to get a list of node version available for installation.
You will see the list like below:
... ... v5.11.1 v5.12.0 v6.0.0 v6.1.0 v6.2.0 v6.2.1 v6.2.2 v6.3.0 v6.3.1
You can install a version by typing nvm install and the version you need, for example.
nvm install v6.3.1
To install another version, type the above commands again with a differnet version at the end.
You can see which versions you have installed by typing:
The result would be:
[root@node ~]# nvm list -> v6.3.1 system
To switch between versions you can do.
nvm use v6.3.1
The result would be:
[root@node ~]# nvm use v6.3.1 Now using node v6.3.1
To set a version as default you can execute.
nvm alias default v6.3.1
the corresponding result shall be:
[root@node ~]# nvm alias default v6.3.1 default -> v6.3.1
An alternative method of installing node.js is from the Epel Repository that is available for CentOS and other linux distro's. To get access to the repo you must first install the epel-release by.
sudo yum install epel-release
Press y for yes and let it install.
After that you can just install node.js from yum.
sudo yum install nodejs
To verify the installed version you can do.
To output shall be:
[root@node ~]# node --version v6.3.1
One way of acquiring Node.js is to obtain the source code and compile it yourself.
To do so, you should grab the source code from the project's website. On the downloads page, right click on the "Source Code" link and click "Copy link address" or whatever similar option your browser gives you.
The current release version that node.js has is v6.3.1. We will download it using wget.
Then we will extract the source archive.
tar xvf node-v6.3.1.tar.gz
And enter the source folder.
Then we will need to install some packages in order to compile the source.
sudo yum install gcc gcc-c++
After all the dependencies are installed we ca now compile and install node.js.
When make is complete you can install node.js using the command.
All is done! Now you can make your scalable network application in the fastest time possible thanks to node.js!