ioBroker.javascript
ioBroker.javascript copied to clipboard
[Bug]: Additional NPM modules aren't loaded/working after each adapter update
I'm sure that
- [X] This issue is still present in the current beta version of this adapter
- [X] There is no other (open) issue with the same topic (use the search!)
- [X] This issue is not described in the adapter documentation / FAQ (read the docs!)
Script type
Blockly, Javascript
The problem
I configured additional "NPM Module" in instances, named "simple-ssh" After a JS adapter update it is almost NOT working, I can see these entries in logs (truncated a bit):
javascript.0 | 2024-03-18 11:53:23.334 | error | script.js.common.MYSCRIPT: SSH is not a constructor
javascript.0 | 2024-03-18 11:53:23.334 | error | at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/build/lib/adapter/adapter.js:8489:62)
javascript.0 | 2024-03-18 11:53:23.334 | error | at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:641:29)
javascript.0 | 2024-03-18 11:53:23.334 | error | at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1390:38)
javascript.0 | 2024-03-18 11:53:23.334 | error | at Object.<anonymous> (script.js.common.1.MYSCRIPT:25:9)
javascript.0 | 2024-03-18 11:53:23.334 | error | at setSwitchPort1PoE (script.js.common.1.MYSCRIPT:5:15)
javascript.0 | 2024-03-18 11:53:23.334 | error | at require (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:528:32)
javascript.0 | 2024-03-18 11:53:23.334 | error | at require (node:internal/modules/cjs/helpers:121:18)
javascript.0 | 2024-03-18 11:53:23.333 | error | at Module.require (node:internal/modules/cjs/loader:1143:19)
javascript.0 | 2024-03-18 11:53:23.333 | error | script.js.common.1.MYSCRIPT: Error: Cannot find module 'simple-ssh'
The usage is inside blockly having a JS function
var SSH = require('simple-ssh');
A workaround is to REMOVE the NPM module, save and restart javascript adapter, and then add it again.
But if you forget it after update, scripts will just fail :(
I just verified it still happening with Adapter v7.9.1
iobroker.current.log (in debug mode!)
No response
Version of nodejs
v18.17.1
Version of ioBroker js-controller
5.0.19
Version of adapter
7.9.1
And this wasn't the case in previous versions/upgrades? The "additional packages" behaviour wasn't changed in the adapter since several month/years.
Hey Matthias, the issue persists since I am using it (maybe a year), so it might be since years. Viele Grüße, Tibor
Just as a link: https://forum.iobroker.net/topic/73531/adapter-update-f%C3%BChrt-zu-neukompilieren-des-npm-moduls
Seems that any installation kicks additional npm modules. Don't know wether this realted in any way but I want to note it.
Ref https://github.com/ioBroker/ioBroker.js-controller/issues/2006
see #1554