SparkFun Inventor's Kit for Edison Experiment Guide

Contributors: ShawnHymel
Favorited Favorite 2

Appendix B: Programming Without the XDK

The IntelĀ® XDK offers some really useful features when programming, such code completion, automatic installation of libraries, and formatting new projects (e.g. templates). However, we totally understand if you don’t want to use the XDK. The good news is that the Edison is a full computer, which means it is more than capable of installing libraries and running code on its own!

Writing Code

There are several ways to write code. Finding a good editor can be a challenge. If you fancy yourself an old-school Unix guru, you might be comfortable with vi. All you need to do is log in to the Edison through SSH or serial and enter the command


You will be greeted with the perhaps familiar vi interface.

vi on the Edison

If you dislike vi but still want to edit code on the Edison directly, you could install another editor. For example, nano has been added to the Edison’s package repositories. See here to install nano.

XDK offers the benefit of editing code on your computer (desktop or laptop) and the ability to send that code directly to the Edison. You can use any number of editors on your personal computer for editing code. For example, Notepad++ for Windows, TextWrangler for Mac, or Emacs for Linux.

Once you are done writing the code, you can send it to the Edison through a number of ways:

  • Copy and paste the code into vi on the Edison and save it
  • Use scp (Linux/Mac) or WinSCP (Windows) to transfer the file(s) from your computer to the Edison
  • Upload the code as part of a GitHub repository and download it on the Edison

Running Node.js

By default, the Edison comes pre-loaded with Node.js, which is the runtime environment used to run JavaScript. To run a Node program written in JavaScript, we just need to enter the command

node <name_of_program>.js

into the SSH or serial terminal of the Edison.

For example, let’s make a simple JavaScript program:

for (var i = 0; i < 3; i++) {
  console.log("Hi " + i);

Save it as test.js in the home directory on the Edison (/home/root). Log into the Edison and make sure we are in the home directory.

cd /home/root

Then, run the program.

node test.js

You should see a few messages printed to the console.

Testing Node.js in the Edison

Installing Node Modules

You can include JavaScript libraries (Node.js modules) in your program by installing them directly on the Edison. From the console, you just need to call

npm install <module name>@<version number>

For example, to install the version of Socket.IO as required by Experiment 5, Part 2, enter the following command into the Edison console:

npm install

Note that this requires the Edison to be connected to the Internet, as it will attempt to find and install Socket.IO v1.3.7 from the npm package repository.

You do not need to create a package.json file (like we did with the XDK) to accompany your code. The npm install command installs the package directly on the Edison. As long as your code as the necessary require('') line, you will be able to use Socket.IO.

A list of available modules can be found on