Closed ghost closed 10 years ago
notify.js contains this code:
var lights = require("rgb-led") var led = require('rgb-led') var Office = new led.wifi370('10.1.1.65')
//send arguments as: red, green, blue //color values are 0-255. Office.writeToLight(255, 255, 255)
This is what turns up when I run it in CMD (before I ran it whitout the node in front)
node notify.js
module.js:340
throw err;
^
Error: Cannot find module 'rgb-led'
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 Object.
please add the following to your notify.js:
var led = require('rgb-led')
I have that:
var lights = require("rgb-led") var led = require('rgb-led') <== here(!!) var Office = new led.wifi370('10.1.1.65')
//send arguments as: red, green, blue //color values are 0-255. Office.writeToLight(255, 255, 255)
ha. oops!
That might be the problem... I was not aware that it's necessary to install it. But as I plan to run the script on Linux, i'll try again on ubuntu.
npm gives error Error: ENOENT, stat 'C:\Users\windows\AppData\Roaming\npm'
npm is not necessary to install it, but one thing npm does is create a folder hierarchy within your project directory that makes modules able to be found by node. I'm strictly a linux user, so I don't know about the availability of npm on windows offhand, but I would expect it could be installed since npm is rather important to the overall node ecosystem.
anyway, to make the module able to be found by require, you can go about it a couple ways. The easiest would be to explicitly specify the file location.
var path = require('path')
var led = require(path.join(__dirname, 'index.js')) //where index.js is rgb-led file.
//It's best to use this method of requiring path and joining with __dirname
//rather than just
//var led = require('./index.js')
//since it allows you to run the node application from anywhere while still
//enabling node to find the package.
Another possibility would be to make your own npm-style folders.
node_modules
in your project directory.rgb-led
under node_modules.This way you should be able to require rgb-led
and node should magically find node_modules/rgb-led/index.js
I booted up Ubuntu now, but I'll test in a few minutes. Thanks for the fast answers :) I got it running in Ubuntu now (can't test the fuction for now, as I don't have the wifi-370, yet)
np; you happened to catch me online! I'll close this issue, but would be happy to help if needed -- matt@chasefox.net
If I try to use this script on Windows 7 Node.JS with the "easy example code" I get the error that an object was expected. As this also turns up when I run notify.js alone I think there's the error. If I run index.js it says "exports is not defined" but I think thats no problem, right?
And a question besides the error: Can you use this script for pulsaiting blue lights on Wifi-370 (started and timed or stopped from python or shell script)?