Q:

nodejs execFile not returning result

I'm trying to call an exe file using childprocess.execFile.  It is not throwing any errors but also not returning any result, which is printed when I run the exe directly from command line.  Code:
var exec = require('child_process').execFile;
var result = '';
var child = exec('file.exe', ['-arg1'], function(err, d) {  
    console.log('err: '+err)
    console.log(d.toString());                       
});
child.stdout.on('data', function(data) {
    result += data;
});
child.on('close', function() {
    console.log(result);
});

A:

Try below code and also check path of file
const { execFile } = require('child_process');
const child = execFile('file.exe', ['-arg1'], null, (error, data) => {
    if(error) {
        console.log(error);
    }

    console.log(data);
});
/....code..../

