Agustus 16, 2012

NodeJS Installation Without OS Package Management

I use Arch Linux for all my OS activities. Arch Linux has NodeJS package and can be easily installed using pacman -S nodejs but you may see that NodeJS has fast release cycle that my Arch Linux package is sometimes left behind and also sometimes I want to use a specific version (for example, Ace - and editor part of Cloud9 IDE - can not work with NodeJS 0.8.x, it needs 0.6.x). Under this scheme, it can be difficult to deal with OS package management. That said, I need to use my own way to resolve this.

So, here is the way to solve the problem. Download the binary version of NodeJS or directly go to http://nodejs.org/dist/ and get the one you need. Extract into specific directory then setup some environment variables into .bashrc so that it will be read automatically whenever I login, or put that into a file and source it whenever I need it. That's all. The details will follow if you are really helpless.

1. Download the binary version. Here I use version 0.8.7:

[bpdp@bpdp-arch nodejs]$ ls -la
total 4320
drwxr-xr-x  2 bpdp users    4096 Aug 17 06:08 .
drwxr-xr-x 22 bpdp users    4096 Aug 16 16:17 ..
-rw-r--r--  1 bpdp users 4401729 Aug 16 06:19 node-v0.8.7-linux-x86.tar.gz
[bpdp@bpdp-arch nodejs]$ 

2. Extract into the directory of your own choice:

[bpdp@bpdp-arch software]$ tar -xzvf ~/master/nodejs/node-v0.8.7-linux-x86.tar.gz
[bpdp@bpdp-arch software]$ ln -s node-v0.8.7-linux-x86 nodejs
[bpdp@bpdp-arch software]$ ls -la
....
....
drwxr-xr-x   6 bpdp users  4096 Aug 16 06:18 node-v0.8.7-linux-x86
lrwxrwxrwx   1 bpdp users    21 Aug 17 06:37 nodejs -> node-v0.8.7-linux-x86
....
....
[bpdp@bpdp-arch software]$ 

3. Set some environment variables

[bpdp@bpdp-arch environment]$ cat nodejs 
NODEJS_HOME=/home/bpdp/software/nodejs

PATH=$PATH:$NODEJS_HOME/bin
MANPATH=$MANPATH:$NODEJS_HOME/share/man
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NODEJS_HOME/lib
C_INCLUDE_PATH=$C_INCLUDE_PATH:$NODEJS_HOME/include
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$NODEJS_HOME/include

export PATH
export MANPATH
export LD_LIBRARY_PATH
export C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH
[bpdp@bpdp-arch environment]$ 

4. Source it whenever you need it:

$ source ~/environment/nodejs

Note: I put the env var into a file: $HOME/environment/nodejs

5. Surely you may also put that into your $HOME/.bashrc for automatic activation.

That's all. Happy coding!

0 comments:

Posting Komentar