Reputation: 43
Apologies for the lack of clarity in my question, I will try and explain here what I mean.
I have some existing code acting as effectively a bridge between different networks (using different protocols). The networks that the bridge is connected to at runtime can change and it is not possible to know the type of networks before runtime. So I need to write something that can effectively request, download, "install" and run a "drivers" whilst in runtime without needing to restart. Is this possible?
I am completely new to node.js and so I am trying to work out if it is possible, otherwise I will have to port the code into Java OSGi I already had (written by someone else).
Upvotes: 4
Views: 483
Reputation: 13570
If drivers are node.js modules, you can put them on npm repository and install via npm programmatically:
var npm = require('npm');
function install (module, callback) {
npm.load({
save : true,
loglevel : 'silent'
}, function (err) {
if (err) return callback(err);
npm.commands.install([module], callback);
})
}
install('express', function (err) {
if (err) throw err;
console.log('Installed!');
});
Unfortunately, this API is not well documented (almost not documented at all), so you have to hack a little to reveal available options.
Upvotes: 3