Wednesday, July 6, 2011

SPDY, Express and Node.js 0.5.0

‹prev | My Chain | next›

There's a new version of node.js out (0.5). It is still considered unstable, but it is likely to be the version out when SPDY Book is complete. So it behooves me to ensure that the instructions for installing express-spdy are correct.

I am mostly following along with the instructions from express-spdy / INSTALL.md (2011-06-23) as I work through this.

First, up I install build-essentials (c++ and more needed to build the later steps) and a few other libraries that experience has taught me to be requirements:
sudo apt-get install build-essential zlib1g-dev git-core python curl
With that, I can install edge-openssl, which is required for the Next Protocol Negotiation (NPN) extensions. I download today's snapshot, which is timestamped on the FTP server:
wget ftp://ftp.openssl.org/snapshot/openssl-SNAP-20110706.tar.gz
I can then un-tar in my $HOME/src directory, build and install:
cstrom@debian:~$ mkdir $HOME/src
cstrom@debian:~$ cd !$
cd $HOME/src
cstrom@debian:~/src$ tar zxf ~/openssl-SNAP-20110706.tar.gz
cstrom@debian:~/src$ uname -a
Linux debian 2.6.32-5-amd64 #1 SMP Wed May 18 23:13:22 UTC 2011 x86_64 GNU/Linux
cstrom@debian:~/src$ cd openssl-SNAP-20110706/
cstrom@debian:~/src/openssl-SNAP-20110706$ ./Configure shared --prefix=$HOME/local no-idea no-mdc2 no-rc5 zlib enable-tlsext linux-x86_64
cstrom@debian:~/src/openssl-SNAP-20110706$ make depend
cstrom@debian:~/src/openssl-SNAP-20110706$ make
cstrom@debian:~/src/openssl-SNAP-20110706$ make install
(On 32 bit machines, I would replace linux-x86_64 in the Configure statement with linux-elf)

Next I configure and install node.js v0.5:
cstrom@debian:~$ wget http://nodejs.org/dist/node-v0.5.0.tar.gz
cstrom@debian:~$ cd src
cstrom@debian:~/src$ tar zxf ../node-v0.5.0.tar.gz
cstrom@debian:~/src$ cd node-v0.5.0/
cstrom@debian:~/src/node-v0.5.0$ ./configure --openssl-includes=$HOME/local/include --openssl-libpath=$HOME/local/lib --prefix=$HOME/local/node-v0.5.0
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok
Checking for library dl : yes
Checking for function SSL_library_init : yes
Checking for header openssl/crypto.h : yes
Checking for library util : yes
Checking for library rt : yes
Checking for CLOCK_MONOTONIC : yes
Checking for fdatasync(2) with c++ : yes
'configure' finished successfully (3.171s)
I am installing all of this locally so no root permissions are required. What is needed is something to pick up the locally installed binaries and shared libraries. Adopting from the node.js blog, I append the following to my $HOME/.bashrc:
# For locally installed binaries
export LD_LIBRARY_PATH=$HOME/local/lib
PATH=$HOME/local/bin:$PATH
PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
CPATH=$HOME/local/include
export MANPATH=$HOME/local/share/man:/usr/share/man

# For node.js work. For more info, see:
# http://blog.nodejs.org/2011/04/04/development-environment/
for i in $HOME/local/*; do
[ -d $i/bin ] && PATH="${i}/bin:${PATH}"
[ -d $i/sbin ] && PATH="${i}/sbin:${PATH}"
[ -d $i/include ] && CPATH="${i}/include:${CPATH}"
[ -d $i/lib ] && LD_LIBRARY_PATH="${i}/lib:${LD_LIBRARY_PATH}"
[ -d $i/lib/pkgconfig ] && PKG_CONFIG_PATH="${i}/lib/pkgconfig:${PKG_CONFIG_PATH}"
[ -d $i/share/man ] && MANPATH="${i}/share/man:${MANPATH}"
done
To ensure those changes are applied, I log out and log back in.

With node 0.5 now in my $PATH, I install the node package manager (NPM) so that I can install express.js:
cstrom@debian:~$ curl http://npmjs.org/install.sh | sh
cstrom@debian:~$ npm install -g express
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: express@2.4.2
npm ERR! Required: {"node":">= 0.4.1 < 0.5.0"}
npm ERR! Actual: {"npm":"1.0.15","node":"v0.5.0"}
npm ERR!
npm ERR! System Linux 2.6.32-5-amd64
npm ERR! command "node" "/home/cstrom/local/node-v0.5.0/bin/npm" "install" "-g" "express"
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/cstrom/npm-debug.log
npm not ok
Aw bummer. A fly in the ointment it would seem.

Sadly, I am forced call it a night there. I will open an issue on the express.js github page to see what is possible here. Unfortunately, even if I can get the maintainer of express.js to relax the node.js version restrictions, I have the feeling that there are other dependencies that require the same changes.

Hopefully those can all be resolved in time for SPDY Book. I have no illusions that SPDY Book will not be quickly out-of-date, but the closer I am to this side of the bleeding edge, the better.


Day #67

No comments:

Post a Comment