Published: 01-08-2016
Getting Node and NPM running on the Raspberry Pi, The precursor to running a web server.
Re-installing Raspian
Having not used the Pi in a while there a was fairly outdated raspbian image on it. It's always good to start a-fresh when you can't remember what it was used for last! So I grabbed the latest image from here and followed these instructions, easy. Plugging the SD card back in and booting up, the default login was pi and password was raspberry. The Pi is a standard Model B, not the newest, not the oldest.
Installing Node and NPM
Installing Node is done by first downloading the pre-built ARMv6 binary, un-packing and moving it to the correct directory:

wget https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-armv6l.tar.xz
tar -xvf node-v4.4.7-linux-armv6l.tar.xz
cd node-v4.4.7-linux-armv6l
sudo cp -R * /usr/local


Next, some file permissions must be corrected. The /usr/local/ folder has root as the owner which will cause problems if I try to install npm packages globally. To stop this ownership of the node folder needs to be taken back. As I don't share these Pi with other users the permissions can just be changed. The following command from the Node documentation sort everything out:

sudo chown -R $(whoami)$(npm config get prefix)/{lib/node_modules,bin,share}


Node serialport problems
Running NPM install everything seems to install just fine. However, when the app starts, the serialport module freaks out and says none of its bindings are working. After a little research it turns out it isn't building itself properly for the ARM instruction set. Installing node-gyb globally and then re-installing serialport seemed to do the trick.
WiFi
I'm trying to attach the Pi to a robotic machine so the WiFi needs to work. The docs explain how to get the WiFi working here Running the sudo iwlist wlan0 scan gets the details of the WiFi network/s. All that's needed is the ESSID which must be placed in the 'wpa-supplicant' config file, found at /etc/wpa_supplicant/wpa_supplicant.conf. The following is placed at the end of the file:

network={
ssid="ESSID"