Adorkable / node-red-contrib-ui-led

A simple LED status indicator for the Node-RED Dashboard
MIT License
16 stars 12 forks source link

Doesn't support apt installed versions of node-red #8

Closed shanness closed 5 years ago

shanness commented 5 years ago

I suspect this is because most of my NR modules are in /usr/lib? (Because I used apt to install it). Here is the error I get.

{ Error: Cannot find module '../../../../../../../../home/craig/.node-red/node_modules/node-red-dashboard'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.requireModule [as require] (/usr/lib/node_modules/node-red/red/runtime/nodes/registry/loader.js:69:16)
    at new LEDNode (/home/craig/.node-red/node_modules/node-red-contrib-ui-led/led.js:35:26)
    at createNode (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:305:18)
    at Flow.start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:89:35)
    at start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/index.js:328:29)
    at /usr/lib/node_modules/node-red/red/runtime/nodes/flows/index.js:164:25 code: 'MODULE_NOT_FOUND' }
yoiang commented 5 years ago

Hmm, I'll have a look through and see if the module is doing anything unusual with its includes or dependencies. node-red-dashboard is a requirement of the module and it shouldn't have any hard declaration to look for the module in a specific relative folder.

yoiang commented 5 years ago

Hey @shanness, I haven't had a chance to reproduce the situation, any change or luck figuring this out?

shanness commented 5 years ago

Hey @yoiang, I don't really know nodejs or node-reds internals, but do have this in

craig@home:~/.node-red$ ls /home/craig/.node-red/node_modules/node-red-dashboard
CHANGELOG.md  Charts.md  config-fields.md  CONTRIBUTING.md  dist  fixfa.js  ISSUE_TEMPLATE.md  LICENSE  license.js  nodes  package.json  README.md  ui.js

And this in ~/.node-red/.config

  "node-red-dashboard": {
   "name": "node-red-dashboard",
   "version": "2.9.8",
   "local": true,
   "nodes": {
    "ui_base": {
     "name": "ui_base",
     "types": [
      "ui_base"
     ],
     "enabled": true,
     "local": true,
     "module": "node-red-dashboard",
     "file": "/home/craig/.node-red/node_modules/node-red-dashboard/nodes/ui_base.js"

The problem seems to be the resolver adding all the ../.. stuff at the start?

{ Error: Cannot find module '../../../../../../../../home/craig/.node-red/node_modules/node-red-dashboard'

As /home/craig/.node-red/node_modules/node-red-dashboard/ exists.

If I go into the dir for the file reporting the error above (/usr/lib/node_modules/node-red/red/runtime/nodes/registry/loader.js), then this works.

craig@home:/usr/lib/node_modules/node-red/red/runtime/nodes/registry$ ls ../../../../../../../../home/craig/.node-red/node_modules/node-red-dashboard
CHANGELOG.md  Charts.md  config-fields.md  CONTRIBUTING.md  dist  fixfa.js  ISSUE_TEMPLATE.md  LICENSE  license.js  nodes  package.json  README.md  ui.js

Does that help at all?

yoiang commented 5 years ago

Is there an entry in the .node-red/.config file for node-red-contrib-ui-led? What does that look like?

shanness commented 5 years ago
  "node-red-contrib-ui-led": {
   "name": "node-red-contrib-ui-led",
   "version": "0.1.1",
   "local": true,
   "nodes": {
    "led": {
     "name": "led",
     "types": [
      "led"
     ],
     "enabled": true,
     "local": true,
     "module": "node-red-contrib-ui-led",
     "file": "/home/craig/.node-red/node_modules/node-red-contrib-ui-led/led.js"
    }
   }
  },
liz-miller commented 5 years ago

I'm having this exact issue too. Does anyone have the fix?

yoiang commented 5 years ago

Folks in #30 who also installed via apt-install say that updating to the latest version of ui_led (0.2.3) and rebooting fixed it for them. I'm not sure why yet but give it a go!

shanness commented 5 years ago

Hey @yoiang , Nah, sorry, didn't fix it. And if anyone is going to try, delete any LED nodes first! I had to manually hack them out of my flows_home.json (couldn't restart after upgrade without removing the existing test LED node.

Still getting this

13 May 23:58:46 - [error] [ui_list:605ba0ac.13ed6] TypeError: Cannot read property 'push' of undefined
While constructing LEDNode widget: { Error: Cannot find module '../../../../../../../../home/craig/.node-red/node_modules/node-red-dashboard'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.requireModule [as require] (/usr/lib/node_modules/node-red/red/runtime/nodes/registry/loader.js:69:16)
    at new LEDNode (/home/craig/.node-red/node_modules/node-red-contrib-ui-led/led.js:13:26)
    at createNode (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:305:18)
    at Flow.start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:89:35)
    at start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/index.js:328:29)
    at /usr/lib/node_modules/node-red/red/runtime/nodes/flows/index.js:164:25 code: 'MODULE_NOT_FOUND' }
yoiang commented 5 years ago

Are you comfortable enough to be able to test a branch without changing anything else? I just pushed https://github.com/Adorkable/node-red-contrib-ui-led/tree/feature/issue8 with a little change to match other libraries scoping of some variables, and may have another idea if that doesn't help.

shanness commented 5 years ago

Hey @yoiang , I removed the existing UI installed version, and ran this craig@home:~/.node-red$ npm install https://github.com/Adorkable/node-red-contrib-ui-led.git#feature/issue8 I restarted NR, then added the LED node to my flow and redeployed, and got the same issue.

Is that the right way to test it?

yoiang commented 5 years ago

Yes, I think that should have installed it properly, dang. You haven't run into this issue at all with any other Node-RED UI nodes either?

Have you raised this in the Node-RED dashboard github? They might know exactly what's going on, I'm at a loss. At some point I'm going to have to recreate your installation, in a container I think.

shanness commented 5 years ago

Hey,

Got the same problem with this other dashbord plugin, and just checked, pretty sure they are the only two UI/dashboard plugins I'm using.

https://github.com/node-red-hitachi/ui_list/issues/7

Haven't rasied in on the dashboard github yet. Are there any other UI plugins you'd suggest I try? Happy to help find one that works?

yoiang commented 5 years ago

You can check here for more contrib-ui, however it's sounding more and more like an issue with node-red-dashboard or with node-red!

shanness commented 5 years ago

Ta, just confirmed getting the same issue with ui-level. And others have reported it too.

https://github.com/hotNipi/node-red-contrib-ui-level/issues/7

I'll move up the line, and perhaps check on discord as the above issue suggests. If I find a solution, I'll update all 3 tickets.

Thanks for your help.

yoiang commented 5 years ago

Hey @shanness, any luck on this front? Or can you paste the thread following this issue so others can follow along?

shanness commented 5 years ago

Hey @yoiang, I haven't had time to do anything about this, and unlikely will any time soon, just too busy with other projects and this isn't pressing enough to chase ATM. Sorry about that.

yoiang commented 5 years ago

No worries! I'm going to close the issue now that it's most likely a Node-RED/Node-RED Dashboard issue. If you do follow up feel free to post the link here.