Is there an MQTT client module available for use with gjs?
I’ve googled and searched this group but found nothing relevant, so assuming the answer is no, a supplementary question:
Is it possible for a gjs app to somehow use modules normally distributed through npm? There’s an npm client module there which I’ve used previously in a nodejs application. Can I use it in a gjs application?
Is it possible for a gjs app to somehow use modules normally distributed through npm?
Yes with a bit of effort depending on what you are trying to use.
If it’s a pure ES module and doesn’t depend on anything extraneous to gjs - you can import it as is from node_modules.
If it depends on globals that gjs doesn’t support, you will need to polyfill them. For example setTimeout, atob, websocket, fetch … I did some (minimal) work there in GitHub - sonnyp/troll: Libraries for GNOME JavaScript (GJS) - check older revisions for things that are now included in gjs if you need to support an older gjs version but I recommend upgrading to 1.72. For now, you can simply use org.gnome.Platform from flathub beta with
It doesn’t look like it would be a week end job though so it’s good I don’t need it immediately. Working with gjs for a couple of weeks has made me start thinking about converting another already existing nodejs app I finished recently.