Possible Duplicate:
node.js execute system command synchronously
I wish to synchronously execute a node.js file from another node.js file. This is what I have but its async.
var spawn = spawn('node', ['./file.js']);
spawn.stdout.on('data',function(data){});
From your comments under the question, it sounds like you don’t want it to be synchronous, and that you don’t care about its output.
If you just want to fire the other process and forget, without watching it or caring about when it ends, what you’re already using (
spawn) does that.If you want to truly fire-and-forget, you’ll want to specify the
detachedoption, so that the child process doesn’t get killed when your process terminates. From the docs:Looking further down, apparently you have to
unrefit as well:And apparently deal with
stdio:So: