I got it to work with the latest version of all software bits on Ubuntu 12 LTS, but it should work with newer versions of Ubuntu too:
Prerequisites
sudo apt-get install libusb-1.0-0-dev libudev-dev libnss3 build-essential
Install Node.js
Download source tarbal, extract it and run:
./configure
make
sudo make install
You can also install the binaries available.
Install NW.js
I just downloaded the 0.12.0 version and extracted it under home folder ~/nw for simplicity
Install nw-gyp
Please follow the nw-gyp installation instructions if required. For me it was sufficient to run this command:
sudo npm install -g nw-gyp
Basic sample
mkdir ~/nw_blinkstick
cd ~/nw_blinkstick
Create file ~/nw_blinkstick/index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node.js <script>document.write(process.version)</script>.
<script>
var blinkstick = require('blinkstick'),
device = blinkstick.findFirst();
if (device) {
var finished = false;
var ledCount = 7;
var index = 0;
var setColor = function () {
console.log(index);
device.setColor("random", {'channel':0, 'index':index}, function() {
if (index == ledCount) {
finished = true;
} else {
index += 1;
setTimeout(setColor, 200);
}
});
}
setColor();
var wait = function () { if (!finished) setTimeout(wait, 100)}
wait();
}
</script>
</body>
</html>
Create file ~/nw_blinkstick/package.json
{
"name": "nw-demo",
"main": "index.html"
}
Now you need to install Node.js package for BlinkStick
cd ~/nw_blinkstick
npm install blinkstick
Important: You have to recompile usb package for NW.js. That’s why you need to install nw-gyp in one of the previous steps.
cd node_modules/blinkstick/node_modules/usb
nw-gyp configure --target=0.12.0
nw-gyp build
Now go back to the sample folder and run the example. Please use sudo if you get permission denied error.
cd ~/nw_blinkstick
sudo ~/nw/nw .
LMK if something does not work and I will be happy to help.