If you want something that closely resembles the top answer but is also synchronous then this will work.
var execexecSync = require('child_process').execSync; var cmd = "echo 'hello world'"; var options = { encoding: 'utf8' }; console.log(execexecSync(cmd, options));