lprhodes / homebridge-broadlink-rm

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

Cannot find module hap-nodejs #540

Open iandronowicz opened 4 years ago

iandronowicz commented 4 years ago

After last update I’m getting this error:

1/16/2020, 8:46:02 PM] ERROR LOADING PLUGIN homebridge-broadlink-rm: [1/16/2020, 8:46:02 PM] Error: Cannot find module 'hap-nodejs'

iandronowicz commented 4 years ago

Solved by manually installing hap-nodejs:

npm install -g hap-nodejs

skb3735 commented 4 years ago

Same issue for me. The above fix didn't seem to work for me though

skb3735 commented 4 years ago

ERROR LOADING PLUGIN homebridge-broadlink-rm Error: Cannot find module 'hap-nodejs'

iandronowicz commented 4 years ago

I think it has something to do with this: https://github.com/ebaauw/homebridge-lib/issues/20

gondalez commented 4 years ago

Same error for me. Full trace:

[1/17/2020, 10:33:56 AM] ERROR LOADING PLUGIN homebridge-broadlink-rm:
[1/17/2020, 10:33:56 AM] Error: Cannot find module 'hap-nodejs'
Require stack:
- /homebridge/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/dist/accessory.js
- /homebridge/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/dist/index.js
- /homebridge/node_modules/homebridge-broadlink-rm/platform.js
- /homebridge/node_modules/homebridge-broadlink-rm/index.js
- /usr/local/lib/node_modules/homebridge/lib/plugin.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:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/homebridge/node_modules/homebridge-broadlink-rm/node_modules/homebridge-platform-helper/dist/accessory.js:13:22)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
[1/17/2020, 10:33:56 AM] ====================
ray-choi commented 4 years ago

Meanwhile I fallback broadlink-rm to version 3.5.5 to make my device works.

npm install -g --unsafe-perm homebridge-broadlink-rm@3.5.5

RMCob commented 4 years ago

Re-installing hap-nodejs, as mentioned above, also worked for me.

sudo npm install -g --unsafe-perm hap-nodejs@latest

calvinyeap commented 4 years ago

Solved by manually installing hap-nodejs:

npm install -g hap-nodejs

Thanks, this works for me.

BereGabor commented 4 years ago

hap-nodejs manual install doesn't work for me.

The solution works is a symlink in node_modules folder in homebridge-broadlink-rm plugin folder:

/homebridge/node_modules/homebridge-broadlink-rm/node_modules # ln -s /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs hap-nodejs

mvaneijgen commented 4 years ago

What @BereGabor said helped me, but I liked to give it some more detail

I had to first allow the homebridge usersto do suds commands, this you do by ssh-ing into the device, for me that was a Raspberry Pi ssh pi@raspberrypi.local

sudo usermod -a -G sudo homebridge 
sudo passwd homebridge #After that give the user a new password
sudo hb-service restart # Restart homebridge

Within the homebridge terminal (after it has restarted)

cd /usr/local/lib/node_modules/homebridge-broadlink-rm/node_modules
sudo ln -s /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs hap-nodejs

After I restarted homebridge Restart Homebridge, my Broadlink RM Pro was detected and everything started working.

agoodshort commented 4 years ago

Using latest Raspbian-Homebridge-v1.0.5.img


Fixed the dependency issue with the below:

$ cd /usr/local/lib/node_modules/homebridge-broadlink-rm/node_modules
$ sudo ln -s /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs hap-nodejs
$ sudo hb-service restart

I think simply installing hap-nodejs directly in /usr/local/lib/node_modules/homebridge-broadlink-rm/node_modules using npm install hap-nodejs could do the trick as well, but I am not 100% familiar with npm.

mike-north commented 4 years ago

http://volta.sh/ may be a potential solution here. Global installation has the downside of one shared version across all things -- volta will use a global collection of versions, while still respecting the version number a tool (i.e., homebridge-broadlink-rm) lists in its dependencies.

MattariOnline commented 3 months ago

I had this issue and just resolved it from a mix of stuff here, and wanted to document what worked:

First, I needed homebridge to have sudo: sudo usermod -a -G sudo homebridge

I wanted it to have no password requirement for sudo (not recommended), so I edited sudoers in debian: sudo nano /etc/sudoers Then added this under the line for root: homebridge ALL=(ALL) NOPASSWD:ALL Alternatively, you can follow as written above and use this to set a password for the homebrige user: sudo passwd homebridge

Once sudo was su-done with (I'm so sorry), I installed hap-nodejs via the homebridge terminal specifically, as it didn't work from ssh: sudo npm i hap-nodejs

One reboot later and my accessory showed back up and works just fine!

I hope that helps someone out; thanks to everyone here for all your info as well!