How to run Node.js on a Raspberry Pi

In this post I’ll take you through the steps involved in getting node.js running on a Raspberry Pi. I’m running  Rasbian “wheezy” (Hard-float) on my Raspberry Pi -available for download here.

Prior to node v0.8.XX the install process was slow and painful – download, extract,build (make) and install (sudo install) . Even with over clocking the Raspberry pi the process took well over an on hour. Now we are down to minutes 🙂

There is now an officially published ARM binary package for node that makes the process a lot simpler to install. I’ve taken this gist and added an additional step to enable you to npm install global packages to you Pi…

Create a new directory

sudo mkdir /opt/node

Download, unzip and copy the code

wget http://nodejs.org/dist/v0.10.13/node-v0.10.13-linux-arm-pi.tar.gz
tar xvzf node-v0.10.13-linux-arm-pi.tar.gz
sudo cp -r node-v0.10.13-linux-arm-pi/* /opt/node

Add a path variable for node

nano /etc/profile

NODE_JS_HOME="/opt/node"
PATH="$PATH:$NODE_JS_HOME/bin"

Recursively change the owner of the files in your /opt/node folder to the current user ( required when when running npm install -g somepackage)

Sudo chown -R $USER /opt/node

Quick reboot and you are up and running, to test it out check the version of node thats running

node -v
v0.10.13

Useful Links
Isaac Schlueter – on why not to do package management with sudo
Latest Raspbian Images

Advertisements

3 thoughts on “How to run Node.js on a Raspberry Pi

  1. Pingback: Node-RED: Ein Baukasten für das Internet der Dinge

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s