I have nodejs installed on a debian distro on my raspberry pi. I have installed nodejs and npm successfully.
I wanted to install the pi-gpio module so i could nodejs to access my gpio pins.
I'm using the root user to cancel out permissions errors. I realize thats unsafe and i have a user setup using the quick2wire-gpio-admin utility.
I navigate to my project folder: /usr/michael/
the director listing looks like:
controller.js - this is my program. It starts a webserver and attempts to do var gpio = require('pi-gpio') and then read a gpio pin.
While in my /usr/michael director i did an npm install pi-gpio.
The install was successful and it placed a node-module folder within my project folder.
var gpio = require("pi-gpio");
My absolute path for the pi-gpio module looks like:
/usr/michael/node-module/pi-gpio/pi-gpio.js
When i require the file as the example states i get an error saying it "cannot find module".
Do i need to modify the require path? Are my permissions screwed up.
I've tried:
require('pi-gpio')
require('./node-module/pi-gpio')
require('./node-module/pi-gpio/pi-gpio.js')
Can someone explain what that require function is looking for?
var gpio = require("pi-gpio");
gpio.read(16, function(err, value) {
if(err) throw err;
console.log(value); // The current state of the pin
});