Node.JS on Raspberry Pi

I have a few applications in mind for my Raspberry Pi, and one uses Node.JS. Compiling and installing node is not difficult, but requires a few tweaks to the standard system before it will compile.

 

I’m using the Debian Squeeze image, and though installing the prerequisites and the majority of the build goes smoothly, I ran into a problem building the V8 engine:

error: #error “For thumb inter-working we require an architecture which supports blx”

This is down to Debian using a default of ARMv4 architecture, to try and target the widest range of devices by default. Unfortunately Node.JS requires ARMv5 architecture, but luckily for us, the Raspberry Pi’s CPU is based on ARMv6, we just need to tell the compiler to use it!

 

To build and install Node.js:

$ sudo apt-get install git-core build-essential libssl-dev (to installed needed packages)

$ mkdir ~/nodeDL && cd ~/nodeDL (to make a temporary place to download and compile)

$ git clone https://github.com/joyent/node.git . (to get a copy of node)

$ git checkout v0.6.15 (to checkout the most recent stable version (at time of writing))

 

next we need to tell the compiler to use the armv6 architecture for the compilation:

$ export CCFLAGS='-march=armv6'

$ export CXXFLAGS='-march=armv6'

and then edit deps/v8/SConstruct around the line 82 mark, to add “-march=armv6”:

'all': {

   'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv6'],

   'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions', '-march=armv6'],

 },

Then comment out lines starting around the 157 mark, to remove the vfp3 and simulator parts. Since this is a JSON-like object, remember to remove the comma on the CPPDEFINES line!

'armeabi:softfp' : {

   'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0']

  # 'vfp3:on': {

  #   'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']

  # },

  # 'simulator:none': {

  #   'CCFLAGS':     ['-mfloat-abi=softfp'],

  # }

 },

 

Then the usual configure, make, make install process, NB I had to manually specify the location of the OpenSSL libpath:

$ ./configure --openssl-libpath=/usr/lib/ssl (to configure the build)

$ make (to compile node (This took 103 minutes on my RPi!))

$ sudo make install (to install)

 

Thats it, you should now have a working Node.JS install!

$ node -v should show you the version number

$ npm -v should show you the version of the Node Package Manager

21 Notes/ Hide

  1. site-to-site reblogged this from elsmorian
  2. anandof86 reblogged this from elsmorian
  3. sdonai reblogged this from elsmorian
  4. petter reblogged this from elsmorian
  5. rasberrypibeginnersguide reblogged this from elsmorian
  6. elsmorian posted this