You can simply have an executable file in your extensionโs folder and have JS code in the extension executable. Running an external executable is described in the resource you linked to or here in MDN .
Example copied from MDN:
var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsIFile); file.initWithPath("myapp.exe"); var process = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess); process.init(file); var args = ["argument1", "argument2"]; process.run(false, args, args.length);
It takes a little more logic to find the absolute path of the user profile in order to determine the path to launch the application, but it is doable.
Now, if you want to interact with node with the extension, you can use HTTP requests as a means of communication.
In Firefox, it's a little weird to embed node, although Firefox itself has a JS engine. A more elegant approach would be to try to get PeerJS to work directly in the context of the Firefox add-on without node. It might be harder, but it should be possible. See For example, this browser server addon.
Yolanda ruiz
source share