3

Can nodejs be installed via nave on your raspberry ?

Does node 0.10.x is working fine when installed this way ?

5

I have not used it on the pi, but there's a node binary in the raspbian repository:

» apt-cache show nodejs
Package: nodejs
Version: 0.6.19~dfsg1-6
Architecture: armhf
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>

You should be able to install this very easily with apt-get install nodejs. The version is more than 6 months old, however.

If that isn't good enough, the node.js crew themselves appear to maintain more recent versions pre-compiled for the pi:

http://nodejs.org/dist/

Currently, the "latest" version links to 0.10.3, for which there is no pi binary. However, there's one for 0.10.2, and there's also one for 0.11.0. Nodejs follows an odd/even version numbering meaning the odd minor numbers are the development branch and the even ones the stable branch. Most people will want the stable.

Those tarballs contain a directory tree:

bin/
lib/
share/

You can unpack this into /usr/local/ on the pi. As root (or with sudo):

mv node-v0.10.2-linux-arm-pi.tar.gz /usr/local/src
tar -xzvf node-v0.10.2-linux-arm-pi.tar.gz
cd /usr/local/src/node-v0.10.2-linux-arm-pi
mv bin/* ../../bin/
mv lib/* ../../lib/

Check if you have a /usr/local/share/man/man1, and if not:

mkdir -p /usr/local/share/man/man1

Once that's there:

mv share/man/man1/* ../../share/man/man1/

Done. Check:

> file /usr/local/bin/node
node: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.1.10, not stripped

Should work, and it does; node on the command line acts as a javascript interpreter. If you've already used node on linux you are good to go. If not, you do not need to use a pi centric tutorial, the oodles that apply to linux generally should be fine. However, worth mentioning is this blog post about setting up a node server to run as a boot service, etc, specifically for the pi. Note that the author of that installs into a dedicated /opt/node directory and not /usr/local.

1

Node.js can be installed on the Pi.

I am not sure about your second question though, I will edit this answer as more info comes up.

This is how you do it:

  1. First we need to download the SSL dev libraries.

    sudo apt-get install libssl-dev
    
  2. Now we need to download the latest stable release of Node.js

    wget http://nodejs.org/dist/v0.6.15/node-v0.6.15.tar.gz
    tar -xf node-v0.6.15.tar.gz
    cd node-v0.6.15
    export CCFLAGS='-march=armv6'
    export CXXFLAGS='-march=armv6'
    
  3. We will use the nano text editor to edit a file.

    nano deps/v8/SConstruct
    
  4. Edit lines 82 and 83 to match the following:

     'all': {
       'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv6'],
       'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions', '-march=armv6'],
     },
    
  5. Then comment out lines 157 - 162

  6. Now comes the longest step.

     make
     make install
    
  7. Lastly, do write this in the terminal:

    pacman -S nodejs
    

That should install node.js I have not tested it, but it should work. Here is my source.

  • Thanks for this solution, I'll try it. I hope the automated installed using nave will be available soon on raspberry though :) – Luc Apr 6 '13 at 11:40
  • 1
    Latest node is 0.10.x – goldilocks Apr 6 '13 at 18:34
  • Also: Looks like node maintains binaries for the pi in that nodejs.org/dist repository, so you don't have to compile it from source (unless you want to). – goldilocks Apr 9 '13 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.