snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 55 forks source link

Version 0.3.0 Error: Cannot find module 'debug' #44

Closed misc2000 closed 8 years ago

misc2000 commented 8 years ago

hi, I have now my first own handler for a SecuritySystem created. After I fixed some missing } in my ABBSecuritySystem.js homebridge is parsing it without any more errors

But then I got this error trace below:

I used the line var log = require('debug')('ABBSecuritySystem'); like in your example. could it be that the debug module is missing in the branch? BR misc2000

[2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] homebridge event didFinishLaunching [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Configuration starts [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] We think homebridge has restored 1 accessories. [2016-10-15 15:08:56] [homebridge-knx.KNX] Reading from config: Device/Accessory 1 of 2 [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Match device [Einbruchmeldezentrale alpha] [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] --compare---------------- [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Comparing 8fde8cf2-c8cb-456a-a6e6-b734e8924dfe === undefined ==>false [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] -----none----------return-undefined-- [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] New accessory found: Einbruchmeldezentrale alpha [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Created new platformAccessory instance: Einbruchmeldezentrale alpha [2016-10-15 15:08:56] [homebridge-knx.KNX] Preparing Services: 1 [2016-10-15 15:08:56] [homebridge-knx.KNX] Preparing Service: #0 with name [Alarmanlage] of ServiceType [SecuritySystem] [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Service constructor called [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] ServiceType defined [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] ServiceType known as function [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] ServiceType has characteristics [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Creating new subtype ID [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Did not find restored service for: Alarmanlage [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] Created service: Alarmanlage [2016-10-15 15:08:56] [homebridge-knx.KNX] info [INFO] customServiceAPI.constructor(service, ABBSecuritySystem) module.js:339 throw err; ^

Error: Cannot find module 'debug' at Function.Module._resolveFilename (module.js:337:15) at Function.Module._load (module.js:287:25) at Module.require (module.js:366:17) at require (module.js:385:17) at Object. (/usr/local/lib/node_modules/homebridge-knx/lib/addins/ABBSecuritySystem.js:10:11) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at new require (module.js:385:17)

misc2000 commented 8 years ago

short update: If I remove this line in the handler var log = require('debug')('ABBSecuritySystem'); and all log lines that us log from the active code homebridge is starting with no errors... As work around I will log with console.log()

snowdd1 commented 8 years ago

Hi! Do a npm install in the homebridge-knx folder! It will install dependencies.

misc2000 commented 8 years ago

yes your right. After that command debug module will be installed and working right. but I need to use: sudo npm install I did include it to my update description on KNX Forum

misc2000 commented 8 years ago

I don't get an error any more with the line var log = require('debug')('ABBSecuritySystem');

But the log lines still don't write anything to the console e.g.: log('INFO: LockTargetState.SECURED = 1');

If I write it like: console.log('INFO: LockTargetState.SECURED = 1'); It is working...

snowdd1 commented 8 years ago

Did you start homebridge with debug enabled, like DEBUG=* /path/homebridge ?

misc2000 commented 8 years ago

no. Sounds like this was my mistake. But how can I write a normal, none debug, log line?

snowdd1 commented 8 years ago

In that case console.log(messagetext) is the default way to write to stdout. And that always.
The debug package helps in getting the code more silent if debugging is done. In case you want to spit out an error you should use 'console.error(messagetext)`