homebridge: TypeError: Class extends value undefined is not a constructor or null
Describe The Bug:
Using hb-service
to update node to v16.13.0 fails at the rebuilding stage. See below logs. Error also presents itself when then restarting Homebridge each time, but doesn’t actually seem to affect Homebridge functionality. Using the command to downgrade node back to 14.18.1 runs and rebuilds successfully, removing all errors.
To Reproduce:
Running in terminal:
sudo hb-service update-node 16.13.0
Logs
When running the command to update node:
pi@homebridge:~ $ sudo hb-service update-node 16.13.0
ℹ Installing Node.js v16.13.0 over v14.18.1...
ℹ Target: /usr/local
✔ Download complete.
✔ Installed Node.js v16.13.0
ℹ Rebuilding for Node.js v16.13.0...
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/socks-proxy-agent/dist/agent.js:114:44)
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)
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/npm/node_modules/socks-proxy-agent/dist/index.js:5:33)
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)
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/npm/node_modules/make-fetch-happen/lib/agent.js:161:25)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/socks-proxy-agent/dist/agent.js:114:44)
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)
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/npm/node_modules/socks-proxy-agent/dist/index.js:5:33)
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)
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/npm/node_modules/make-fetch-happen/lib/agent.js:161:25)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
Error: Command failed: npm rebuild --unsafe-perm
✖ ERROR: Failed Operation
ℹ Restarting Homebridge Service...
✔ Homebridge Restarted
pi@homebridge:~ $
From then restarting Homebridge each time:
[27/10/2021, 09:34:39] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[27/10/2021, 09:34:44] [HB Supervisor] Restarting Homebridge...
[27/10/2021, 09:34:44] [HB Supervisor] Starting Homebridge with extra flags: -I -D
[27/10/2021, 09:34:45] [HB Supervisor] Started Homebridge v1.3.6-beta.1 with PID: 10554
Initializing HAP-NodeJS v0.9.6...
[27/10/2021, 09:34:46] Loaded config.json with 0 accessories and 8 platforms.
[27/10/2021, 09:34:46] Loaded 0 cached accessories from cachedAccessories.
[27/10/2021, 09:34:46] ---
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/socks-proxy-agent/dist/agent.js:114:44)
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)
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/npm/node_modules/socks-proxy-agent/dist/index.js:5:33)
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)
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/npm/node_modules/make-fetch-happen/lib/agent.js:161:25)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
[27/10/2021, 09:34:47] Loaded plugin: homebridge-config-ui-x@4.41.3-test.2
[27/10/2021, 09:34:47] Registering platform 'homebridge-config-ui-x.config'
[27/10/2021, 09:34:47] ---
Environment:
- Node.js Version: 14.18.1 -> 16.13.0
- NPM Version: 6.14.15 -> 8.1.0
- Homebridge Version: 1.3.6-beta.1
- Operating System: Raspbian (HB Image)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 34 (7 by maintainers)
Thanks to @sw33tT and @SeydX for your fixes. I will rewrite here what seems to be working for most users (seydx solution):
@christiantschoerner for future reference you should avoid using odd (as opposed to even) version numbers of node as they aren’t supported by homebridge. doesn’t mean it won’t work… but it’s not recommended
Had the same error. This worked for me thanks but I used Node 15.13.0!
Try install node with n (Node-Package-Manager)
-> sudo hb-service stop
-> sudo npm cache clean -f
-> sudo npm install -g n
-> sudo n lts
-> sudo reboot
new ssh connection to your homebridge
-> cd /usr/local/lib/node_modules/
-> sudo npm rebuild --unsafe-perm
This steps are working for me.
sudo hb-service update-node give me the same errors.