How can I use the modules loaded from other Node process from another Node process.
Example I run:
node my_modules
which load MyModule
then I will run another nodejs process:
node grab_modules
which will run GrabModule
GrabModule
will attempt to use the functions inside MyModule
Is this possible? And if this is possible how?
What you want is probably dnode:
From the README of dnode:
The server (which hosts the functions to be run):
var dnode = require('dnode');
var server = dnode({
zing : function (n, cb) { cb(n * 100) }
});
server.listen(5050);
The client (which calls functions on the server and gets their results in a callback)
var dnode = require('dnode');
dnode.connect(5050, function (remote) {
remote.zing(66, function (n) {
console.log('n = ' + n);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With