user2855405
user2855405

Reputation: 515

How to resolve 'cannot find module 'serialport' using Node.js and Johnny-Five?

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)

Upvotes: 2

Views: 7253

Answers (2)

prro
prro

Reputation: 1

Just add:

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

Upvotes: 0

Redben
Redben

Reputation: 21

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

Upvotes: 2

Related Questions