lprhodes / homebridge-broadlink-rm

Broadlink RM Mini and Pro plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
571 stars 284 forks source link

[Fixable] ERROR LOADING PLUGIN homebridge-broadlink-rm: Cannot find module 'hap-nodejs' #574

Open benncarroll opened 4 years ago

benncarroll commented 4 years ago

Hey Luke,

First off just want to say huge thank you from me and everyone who uses your amazing plugin!

I am getting the following error casuing homebridge to crash on launch, after upgrading homebridge-broadlink-rm to v3.6.22

ERROR LOADING PLUGIN homebridge-broadlink-rm
Error: Cannot find module 'hap-nodejs'
Require stack:
 - /usr/lib/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/dist/accessory.js
 - /usr/lib/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/dist/index.js
 - /usr/lib/node_modules/homebridge-broadlink-rm/platform.js
 - /usr/lib/node_modules/homebridge-broadlink-rm/index.js

Then further down, as a result of the above:

Error: The requested platform 'BroadlinkRM' was not registered by any plugin
...
Got SIGTERM, shutting down Homebridge...

I believe a dependency 'homebridge-platform-helper' is missing a dependency of 'hap-nodejs'

As below, it can be fixed by manually installing this package.

Thanks again!

People looking for a quick fix!

Run the following command to install hap-nodejs manually and allow the plugin to run.

npm i -g hap-nodejs
benncarroll commented 4 years ago

Forgot to add my versions & details:

asafdavid230 commented 4 years ago

Hi, @lprhodes I've got the same issue too, hap-nodejs installation doesn't helped me.

fizulnizam commented 4 years ago

I am in the same boat with asafdavid230

rfroom commented 4 years ago

I have the same issue as benncarroll and asafdavid230 even after installing hap-nodesjs manually

Supereg commented 4 years ago

Hap-nodjes must not be added as a dependency by a homebridge plugin. It must always use the instance passed by the Homebridge API

fizulnizam commented 4 years ago

So how do we solve this? @Supereg

Supereg commented 4 years ago

Homebridge api object has the hap property where everything from hap-nodejs is exposed. This is just something the author must fix in his code.

jeylites commented 4 years ago

I'm having the same issue, Homebridge crashes after I include the broadlink config, then I get the following error. Any ideas of a workaround? @lprhodes

[8/16/2020, 07:36:44] ERROR LOADING PLUGIN homebridge-broadlink-rm:
[8/16/2020, 07:36:44] Error: Cannot find module 'hap-nodejs'
Require stack:
- /usr/local/lib/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/dist/accessory.js
- /usr/local/lib/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/dist/index.js
- /usr/local/lib/node_modules/homebridge-broadlink-rm/platform.js
- /usr/local/lib/node_modules/homebridge-broadlink-rm/index.js
- /usr/local/lib/node_modules/homebridge/lib/plugin.js
- /usr/local/lib/node_modules/homebridge/lib/pluginManager.js
- /usr/local/lib/node_modules/homebridge/lib/api.js
- /usr/local/lib/node_modules/homebridge/lib/server.js
- /usr/local/lib/node_modules/homebridge/lib/cli.js
- /usr/local/lib/node_modules/homebridge/bin/homebridge
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/src/accessory.ts:3:1)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
[8/16/2020, 07:36:44] ====================