Made with bytes - Web Development and Consultancy, London UK

Install node.js and coffescript inside a python virtualenv

Sat 31 April 2011

java-script.png

If you want to use coffee-script or node.js into a project using python virtual environments without having to fiddle with your entire system, here is a quick guide on how to do it.

Usually when developing I like to keep my projects self-contained, keep all dependencies in the same enviroment, this is where virtualenv and virtualenv_wrapper come in handy.

1. Activate the virtualenv:

$ workon test

2. Move inside the virtualenv directory:

(test)$ cdvirtualenv

3. Export the directory as the prefix for the installation:

(test)$ export PREFIX=`pwd`

4. Get the latest version of node.js from http://nodejs.org/ and unpack it e.g.

(test)$ wget http://nodejs.org/dist/v0.6.6/node-v0.6.6.tar.gz
(test)$ tar xvfz node-v0.6.6.tar.gz

5. Once inside the unpacked node directory:

(test)$ ./configure --prefix=$PREFIX
(test)$ make
(test)$ make install

6. Check that node.js was installed correctly:

(test)$ which node

7. Fortunately npm (node package manager) is installed with node.js as well, now we can proceed with the installation of coffee-script:

(test)$ npm install -g coffee-script

npm uses the PREFIX environment variable to determine where to install the node packages, bear this in mind in case you plan to install any other packages.

8. Check that coffe-script was installed successfully:

(test)$ which coffee

9. Play with node.js or coffee-script :)

If you found this useful or there is something not quite right

Photo credit: jenny-pics on flickr