Setup Node.js on Raspberry Pi 2 B

Recently I picked up one of new Raspberry Pi 2 Model B microcontrollers. Most people who play with these seem to use Python or Java for coding... but me, I'd much rather use JavaScript. For that, the solution is to run Node.js on the Pi. These are the steps I used ot get it working.

The Raspberry Pi can have a keyboard & mouse connected via USB, a hardwired ethernet cable & HDMI cable to a monitor for everything to work... well and power. However I'd much rather work with it in a "headless" mode where all I plug in is a WiFi USB adapter & power. Then once it boots up (which is quite fast) and connected to the network (which is automatic if it sees your network from a previous configuration), you connect via SSH on the command line to do all work... so I'll show that here.

Run Through Initial Config of Raspberry Pi

Run through the setup... it's quick once you have the OS on the memory card. I did all this with a computer setup (USB mouse, keyboard, HDMI cable to external monitor).

Setup WiFi

I used the Edimax EW-7811Un 150Mbps 11n WiFi USB Adapter. Once you plug it in, within the Raspbian GUI (get to it from a command line by running startx) open the WiFi settings. You have to manually find your network SSID, select it and enter the password. Then reboot the Pi... (from the terminal: sudo reboot)... when it reboots you should be online.

To be safe, grab the IP of the Pi. Now you can go headless.

Setup Host Computer

First, make sure your host (laptop) is setup.

Get Network Scanner to Find the Pi

You'll need to find your Pi on your network if its headless and you don't know it's IP. I used nmap. On MacOS this is available via homebrew:

$ brew install nmap

Find your Raspberry Pi

To use it, from the command line, tell it to scan your network for machines with port 22 open (the SSH port):

$ nmap -p 22 --open -sV 192.168.0.* -Pn

The above says scan my network, specifically all IPs on 192.168.0.any that have port 22 open. The last argument isn't required but I had to do it.

You are looking for a response that includes OpenSSH 6.0p1 Debian... that's Raspbian Wheezy so it's likely our Pi. Near that line, a few lines above it, it should say the actual IP it was scanning when it got that. Here's what mine said: