I'm trying to move my bb-8(sphero) with cylon.js. I installed node.js, cylon-ble module globally and made simple code to move my bb-8.
My environment is
The following error occurred while executing bb-8.js.
$ node bb-8.js
module.js:327
throw err;
^
Error: Cannot find module 'cylon'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/tomo/NodeJS/bb-8/bb-8.js:1:75)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
bb-8.js
var Cylon = require('cylon');
Cylon.robot({
connections: {
bluetooth: { adaptor: 'central', uuid: 'e6677e25df494211864219ce120ca051', module: 'cylon-ble'}
},
devices: {
bb8: { driver: 'bb8', module: 'cylon-sphero-ble'}
},
work: function(my) {
my.bb8.color(0x00FFFF);
after(500, function() {
my.bb8.color(0xFF0000);
});
after(1000, function() {
my.bb8.roll(60, 0);
});
after(2000, function() {
my.bb8.roll(60, 180);
});
after(3000, function() {
my.bb8.stop();
});
}
}).start();
I checked modules, seems ok.
$ npm ls
/Users/tomo/NodeJS/bb-8
└── (empty)
$ npm ls -g | grep cylon
├─┬ cylon-ble@0.10.1
│ ├── cylon@1.2.0
Any help would be appreciated.
You should install cylon module locally since is a dependency of your proyect or set NODE_PATH env variable.
$ cd /Users/tomo/NodeJS/bb-8
$ npm install cylon
It's recommended use
$ npm init
$ npm install --save cylon
In order to write that dependency in your package.json for future installations.
Take a look here for a better explanation about how Node.js search for modules in your projects.