hannseman / homebridge-mi-hygrothermograph

Homebridge plugin for the Xiaomi Mi Bluetooth Temperature and Humidity Sensor
MIT License
264 stars 52 forks source link

node.js 16.13.0 breaks the code #168

Closed jpensar closed 2 years ago

jpensar commented 2 years ago

Expected Behavior

The plugin should start normally (did before with Node-js version 14)

Current Behavior

The plugin is not loaded, error related to bluetooth_hci_socket.node compiled with wrong version of Node-js. Following the advice in the log file, npm rebuildornpm install`, will not help

Steps to Reproduce (for bugs)

Versions

Configuration

Homebridge Log / Command Output

[03/12/2021, 13:48:33] ERROR INITIALIZING PLUGIN homebridge-mi-hygrothermograph:
[03/12/2021, 13:48:33] Error: The module '/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/lib/binding/bluetooth_hci_socket.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/lib/native.js:6:15)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
hannseman commented 2 years ago

Hi! I run this plugin on 16.3.0 and it works fine. As described in the error message the installed version of this plugin was compiled against an older node version and you need to reinstall it. The easiest way in my experience is just to remove the homebridge-mi-hygrothermograph directory and then install the latest version, i.e:

rm -rf /usr/local/lib/node_modules/homebridge-mi-hygrothermograph/
npm install -g homebridge-mi-hygrothermograph

Also see: https://github.com/hannseman/homebridge-mi-hygrothermograph/issues/124