Node js module in Openhab script

Hello to everyone, my topic is just a question, is it possible to use node lib of node module directly in Openhab script? Why if install a local module by npm I can find the modules directory also in the Openhab sitemaps directory?
I’m just a beginner and I’ve installed a openhabian 2.2 on my raspberry.
Thanks to everyone

What exactly are you trying to accomplish? If you just want to reference the same node_modules folder, yes you can. You just have to know the path. But doing that is not how node modules are supposed to be designed. What you’re trying to do is basically piggybacking another app’s dependencies. If you create your own node module, create a package.json with your own dependencies in it.

Hi, I would do a openhabian script with some node lib that are in my package module. As for me it’s impossible to control my Yeelight by the binding SNAPSHOT 2.1.0 or by MIIO binding, I successfully controlled its by yeelight2 node lib. So I’m trying to merge the two world. Thanks

I use node-red as the bridge between node.js and openHAB

https://nodered.org/

and the node-red-contrib-openhab2 nodes

If you’re already in a node lib, use the HTTP server in node and create your own rest API.