tsightler / ring-mqtt

Ring devices to MQTT Bridge
MIT License
589 stars 105 forks source link

Bug: rest-client not found #892

Closed DaveDixon closed 2 months ago

DaveDixon commented 2 months ago

Is there an existing issue for this?

Is this really a bug or just a usage/support question?

Have you read and followed any recommendations in the Support and Troubleshooting section of the wiki?

Did this issue start after an upgrade?

Are you prepared to respond and provide all relevant information (logs, screenshots, etc)

Describe the Bug

Fresh install, fails with Cannot find module '/opt/ring-mqtt/node_modules/ring-client-api/rest-client' imported from /opt/ring-mqtt/lib/tokenapp.js

Steps to Reproduce

systemd start ring-mqtt.service

Expected Behavior

The daemon to start successfully

Log Output

ode:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/ring-mqtt/node_modules/ring-client-api/rest-client' imported from /opt/ring-mqtt/lib/tokenapp.js
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:327:11)
    at moduleResolve (node:internal/modules/esm/resolve:980:10)
    at defaultResolve (node:internal/modules/esm/resolve:1193:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  url: 'file:///opt/ring-mqtt/node_modules/ring-client-api/rest-client',
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.19.1

Screenshots

No response

Config File

{
    "mqtt_url": "mqtt://localhost:1883",
    "mqtt_options": "",
    "livestream_user": "",
    "livestream_pass": "",
    "disarm_code": "",
    "enable_cameras": true,
    "enable_modes": false,
    "enable_panic": false,
    "hass_topic": "homeassistant/status",
    "ring_topic": "ring",
    "location_ids": []
}

Install Type

Manual

Version

5.7.1

Operating System

Ubuntu 24.04

Architecture

x86_64

Machine Details

Physical x86_64

tsightler commented 2 months ago

This is not a bug, this is a basic dependency issue with the installation, either npm install has not been run or for some reason it failed to properly install all dependencies in the proper location. As stated in the wiki regarding manual installs, this installation method is "on your own", because I don't have time to help people that don't know how to install and troubleshoot things to work through every issue they might have. If you are performing a manual install, the expectation is that you have these skills on your own.

If you can reproduce the above issue with a docker install, feel free to open a bug.

DaveDixon commented 2 months ago

Ok, thanks, I understand. I've been using your code since you put it up here and I very much appreciate it. I did the npm install and if you think that's the culprit, I'll look there. Thanks again!

DaveDixon commented 2 months ago

The wiki documentation says "NodeJS version should be 18.16.0 or later", but the npm install says node: '>=20'. nodejs for Ubuntu 24.04 is v18.19.1. Downloaded Node.js v20.17.0 and the daemon now runs successfully.

tsightler commented 2 months ago

Thanks for the update. I'll update the wiki. Like it says in the manual installation section, I don't test manual install at all these days, although technically my development environment is a "manual" install. I'm actually quite surprised that NodeJS 18 wouldn't work as it has fetch, which is the only thing I know that is really required in the newer versions, but the container versions have all been updated to include NodeJS v20 and that's all I've tested recent versions on, I don't go back and test older versions.

DaveDixon commented 2 months ago

Looks like push-receiver's preference:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@eneris/push-receiver@4.1.5',
npm WARN EBADENGINE   required: { node: '>=20' },
npm WARN EBADENGINE   current: { node: 'v18.19.1', npm: '9.2.0' }
npm WARN EBADENGINE }
tsightler commented 2 months ago

Hmm...I knew push-receiver preferred >=20, but I thought it would still work on 18. Good catch and I've updated the wiki. Thanks for providing an update here so that I knew what to change, it is appreciated. I know that are people that still prefer to use manual install, I just don't have time to go back and try to test it especially when ~99% of users just leverage the addon or docker. I try to remember to check things every now and then, but little things like a dependency that bumps can be easily missed since everything in my lab is already on v20.