If you're starting from scratch, you will need to run through the following instructions after installing Raspbian:
curl http://nodejs.org/dist/v0.10.1/node-v0.10.1.tar.gz | tar xz cd node-v0.10.1 ./configure make make install
To test if you have installed this properly run this command:
Node.JS comes with NPM (Node Package Manager) that allows you to retrieve libraries with ease making development much easier; however NPM uses GIT that is not included by default in the operating system. You can download it using the apt-get installer:
sudo apt-get install git
To start, we need to create a folder that will house our application.
mkdir ~/web-based-phy-comp cd ~/web-based-phy-comp
To develop the web interfaces for node, we need a few libraries at our disposal to make the process of development easier and to enable real-time communication between our web interfaces and the hardware. Once we've done that, we can create a manifest for our application that will tell Node.JS which dependencies we are using.
This code package.json contains the JSON structure required to start a project and install the required dependencies for this project. We can then run the Node Package Manager (NPM) to install all dependencies:
The code to run this is
attached to this document available from GitHub. It is commented to introduce you to developing with Express, EJS, Socket.IO and OnOff.
When you're ready to run your application, go to the application’s root directory and run the following command:
sudo node ./app.js
You can then launch a web browser and go to the following address to start interacting with your circuit: