ioBroker / ioBroker.javascript

Script engine for JavaScript and Blockly
MIT License
325 stars 120 forks source link

Use js-controller v6 methods to manage node modules #1554

Closed foxriver76 closed 4 months ago

foxriver76 commented 5 months ago

Is your feature request related to a problem? Please describe. Currently when installing user defined node modules, npm will clean them at every operation, leading to the module not being available until a restart of javascript adapter.

Describe the solution you'd like js-controller v6 introduces new methods with https://github.com/ioBroker/ioBroker.js-controller/pull/2650 to install and require node modules without running into this issue

Describe alternatives you've considered None

Additional context Code needs to check if methods available if yes use this method else stick to old behavior

Only for implementing developer: To test the feature locally with the js-controller v6, simply install iobroker.js-controller@dev

klein0r commented 5 months ago

Only for implementing developer: To test the feature locally with the js-controller v6, simply install iobroker.js-controller@dev

@dev is 5.0.20-alpha.0-20240502-e03492751 instead of 6.x ?

foxriver76 commented 5 months ago

Yes, at development time there is no v6

klein0r commented 5 months ago

@foxriver76 Please review 3bc5b19d35c7ca7f38eb17b99d9deaf899abc007

foxriver76 commented 5 months ago

Thanks a lot, LGTM in general :+1:

I think this should be awaited too https://github.com/ioBroker/ioBroker.javascript/commit/3bc5b19d35c7ca7f38eb17b99d9deaf899abc007#diff-58417e0f781b6656949d37258c8b9052ed266e2eb7a5163cad7b0863e6b2916aR1813

Do you know if there is also code somewhere to remove the node modules?

klein0r commented 5 months ago

Do you know if there is also code somewhere to remove the node modules?

At the moment: no.

Can you provide some function to get all installed packages for the current namespace? In that case I could remove all packages which are not in the packages list of the instance.

foxriver76 commented 5 months ago

Yes, so we need something like a adapter.listInstalledNodeModules() returning a string array with the package names. I can implement no problem.

foxriver76 commented 5 months ago

Please have a look if this will be suitable for you: https://github.com/ioBroker/ioBroker.js-controller/pull/2723