homebridge/homebridge-config-ui-x

Error missing '../lib/cli.js' when installing a plugin using HomeBridge 1.8.0

Closed this issue · 5 comments

Current Situation

Hi when I update a plugin from HomeBridge UI (running on Raspberry Pi) I get a message about a missing '../lib/cli.js' component.

This is a strange error because this module is visible in homebridge lib folder. Any help ?

Logs

USER: HAP.Admin
DIR: /var/lib/homebridge
CMD: npm install --save homebridge-pichler-pkom4@1.1.5-beta.4
node:internal/modules/cjs/loader:1137
throw err;
^

Error: Cannot find module '../lib/cli.js'
Require stack:

  • /opt/homebridge/lib/node_modules/npm/bin/npm-cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object. (/opt/homebridge/lib/node_modules/npm/bin/npm-cli.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/opt/homebridge/lib/node_modules/npm/bin/npm-cli.js' ]
    }

Node.js v18.19.0

Operation failed with code 1.

You can download this log file for future reference.

See https://github.com/homebridge/homebridge-config-ui-x/wiki/Troubleshooting for help.

Config

No response

Homebridge UI Version

4.56.1

Homebridge Version

1.8.0

Node.js Version

v18.19.0

Operating System

Official Homebridge Raspberry Pi Image

Environment Info

None

Raspberry Pi Model

Raspberry Pi Zero 2 W

An update on this issue. I tried to identify if it could be fixed using latest node 20.x version, homebridge 1.7.0 or earlier versions of homebridge-ui. This only setting that avoid this situation is the Insecure mode. As soon as Insecure mode is disabled in Homebrige (no longer allowing accessory control) npm updates fail and homebridge restart never ends.

There's definitely an issue between Homebridge 1.8.0 and Node 20.12.2. Simply install both of them on a vanilla Raspberry (Debian GNU/Linux Bookworm 12) and restart the Raspberry. You'll see that it no longer starts.

ERROR: npm v10.5.0 is known not to run on Node.js v20.12.2. This version of npm supports the following node versions: ^18.17.0 || >=20.5.0. You can find the latest version at https://nodejs.org/.

Hi @jtasoftware

i'm afraid i haven't been able to reproduce this on my pi with HB 1.8.0, node 20.12.2 and turning off insecure mode.

have you tried a node reinstall/rebuild with

sudo hb-service update-node 20.12.2

if it skips because the version is already installed, you could try

sudo hb-service update-node 20.12.1

then

sudo hb-service update-node 20.12.2

I didn’t find any workaround so far (reinstalling homebridge, turning insecure, etc). Only rebuilding the Pi did fix.

My findings are:

  • If I run secure mode using homebridge 1.8.0 I get the missing npm.cli error with both npm 20.12 and 18.19.
  • If I update to 20.12.2 I get installation errors at the first homebridge update and the service will no longer restart.
  • Homebridge logs (posted previously) mention a compatibility issue between npm 10.5 and node.js 20.12.2
  • One of my older pi using previous version of Rasbian do not have this issue.

I will try again more tests.

Did you tested using latest Homebridge for Raspberry 64 bit image (2024.01.08) ?

Hi an update on this issue: I rebuilt the Pi using a different SDCard (premium brand) and all instabilities disappeared.

No more problems or error messages while turning off the Insecure Mode.

No more errors messages after upgrading to node 20.12.2 (compatibility warning are still there but do not seem to be a problem).