The Wonderful World Of Linux

Linux, Mac, Web Hosting and Whatnot

Install Node and NPM Without Compiling

| Comments

You can easily install NodeJS with NPM via your default repository. If it isnt in there, due to the popularity, its likely in one of the many community repositories such as the EPEL and RPMForge repositories, but unfortunately they are rarely up to date. Luckily, getting the latest version of node and npm could not be easier! Lets get started by grabbing some dependencies:

Prerequisites

Ubuntu

1
sudo apt-get install g++ curl libssl-dev apache2-utils

CentOS

You can just grab all the development tools

1
yum -y groupinstall "Development Tools"

Installing the Precompiled Binary

This is by far the easiest way as there is no compiling what so ever, the nice folks at NodeJS have done all that for you! However, because it is precompiled you may run into some issues but I personally havent experienced any yet.

1
2
3
4
cd /usr/local/src
wget http://nodejs.org/dist/latest/$(curl http://nodejs.org/dist/latest/ 2>1  | grep linux | sed -e 's/<[^>]*>//g' | awk '{print $1 }' | grep $([[ $(getconf LONG_BIT) = 64 ]] && echo x64 || echo x86))
cd node-*
rsync -Pav {bin,lib,share} /usr/

We first start by switching into our src directory. I like doing this as having random source files spread out in /root and /home can be awfully messy. The very next line is a fancy wget statement that curls the nodejs latest folder, grep’s for linux, strips out the html and then greps for whichever result matches your architecture and then downloads it! Pretty fancy! Followinng this we cd into the newly untarred directory and simply rsync the binary and library files. Thats it! You can verify by running the following:

1
node -v ; npm -v

If its copied correctly, those commands will not error out.

But I Like Compiling!!!

Well fine then, luckily its just as easy!

1
2
3
4
5
6
cd /usr/local/src
git clone git://github.com/ry/node.git
cd node
./configure
make
make install

And thats that! Enjoy Node!!

Comments