I have a file that needs to export the output of a command performed by 'node-cmd' package. But module.exports
cannot be run inside closure. How do i somehow set the closure output to global scope and use it? Simplified not working code example below.
const cmd = require('node-cmd');
let node_ver;
cmd.get('node -v', (err, data, stderr) => node_ver = data);
module.exports = node_ver;