2
votes

Main goal: using Johnny-five and node.js to run a script for my Arduino, using LeapMotion Controls

I have a folder with my

1: 'robotarm.js' script

2.the Leapjs 'lib' folder

  1. the 'node_modules' folder in leapjs which has underscore, glmatrix and ws.

I am have uploaded the Standard Firmata on the Arduino Board and I am trying to run my Script to start the program. However when I go to terminal, get inside my proj folder and type node robotarm.js, this is what happens:

 Kriss-MacBook-Pro:armproj Kris$ node robotarm.js

 module.js:340
throw err;
      ^
Error: Cannot find module 'serialport'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Board.Serial.detect (/Users/Kris/node_modules/johnny-five/lib/board.js:69:7)
at new Board (/Users/Kris/node_modules/johnny-five/lib/board.js:299:23)
at Object.<anonymous> (/Users/Kris/Desktop/armproj/robotarm.js:90:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
2
Did you try npm install -g serialport - sol4me
I wouldn't install serialport globally. That's not what you want. Delete your node_modules folder and try npm install johnny-five (or npm install if you have it in packages.json). There was an inconsistency with the node-serialport binaries which required a build in some environments... and I am guessing that your build failed the last time you tried this. Try installing J5 again. LMK if you run into any further troubles. - Brian Genisio
@user2855405 Did you figure out your problem? - Brian Genisio

2 Answers

2
votes

Just npm install (not globally) did the trick for me. I didn't even have to delete my node_module folder.

0
votes

Just add:

var board = new five.Board({ port: "COM3" });