Recently I wanted to install node.js on ec2 linux machine and to my surprise this task turned to be a little more tedious than I thought it would be. The reason for that is mainly because there are many ways to do it each of them with their pros and cons. The only alternative that I found easier to follow was to run the command: "sudo yum install nodejs npm --enablerepo=epel" . Unfortunately the epel repository has a very old version of node so I had to stick with a better option.
In this topic I am going to cover the option to download the binaries and just add the node directory to path.
The steps:
1. Go to https://nodejs.org/dist/ and select the version of node.js that you want. Normally you will need the latest. When I did the installation i used https://nodejs.org/dist/v4.2.1/node-v4.2.1-linux-x64.tar.gz .
2. After selecting the url that you want go to your machine and create a folder to have your node installation (be sure that the owner of the folder is ec2-user, if not change it with chown). In my case I created /opt/ . Then download your package with the command: wget https://nodejs.org/dist/v4.2.1/node-v4.2.1-linux-x64.tar.gz
3. Uncompress the file with command: tar -xvzf node-v4.2.1-linux-x64.tar.gz and then navigate to created folder. In my case it was node-v4.2.1-linux-x64
4. The last step now is to add the node bin directory to path. To do so just create a new file in /etc/profile.d/node.sh . Edit the file and add the line: pathmunge /opt/node-v4.2.1-linux-x64/bin/ . Save the file and then run:
source /etc/profile to refresh profile and you are ready.This should normally be enough to have your node installation up and running.

1 comment:
Hello ...
I want to try Linux someday. Much thanks for this tutorial ....
regards
Tangki Panel
Post a Comment