Node.js installation with Stow

I decided to install node.js from source since the package shipped with Debian is not very up-to-date. In such occasions tools like stow or xstow comes in handy.

From official documentation of GNU Stow:

GNU Stow is a symlink farm manager which takes distinct packages of software and/or data located in separate directories on the filesystem, and makes them appear to be installed in the same place. For example, /usr/local/bin could contain symlinks to files within /usr/local/stow/emacs/bin, /usr/local/stow/perl/bin etc., and likewise recursively for any other subdirectories such as .../share, .../man, and so on.

I use XStow which is a replacement of GNU Stow written in C++. It supports all features of Stow with some extensions.

How to install node.js using Stow

Make sure you have write access to the /usr/local directory as a regular user. On Debian you have to belong to "staff" group. In my case:

# adduser martink staff

Look up the current version of node.js on node.js homepage and create the target stow directory for the node.js installation:

$ mkdir -p /usr/local/stow/node-v0.8.18

Clone node.js sources:

$ git clone https://github.com/joyent/node.git

Checkout current version of node.js:

$ git checkout v0.8.18

Configure node.js for installation under /usr/local; build the sources:

$ cd node
$ ./configure
$ make

Install node.js to the target stow directory:

$ make DESTDIR=/usr/local/stow/node-v0.8.18/ install

Get rid of the "usr/local" in the directory path under the target stow directory:

$ cd /usr/local/stow
$ mv node-v0.8.18/usr/local/* node-v0.8.18/
$ rm -rf node-v0.8.18/usr

Create directory where additional node.js modules will be installed:

$ mkdir -p /usr/local/lib/node_modules

Install the node.js package using xstow:

$ xstow node-v0.8.18

Verify that node.js is successfully installed:

$ node -v
v0.8.18

Tags: 

Subscribe to Comments for "Node.js installation with Stow"