How to execute an .exe from node.js?

0

I've been trying to run a .exe from NodeJs with the following code:

var exec = require('child_process').execFile 

var fun =function() {
   console.log("fun() start");
   exec('ExecFileTest.exe', function(err, data) {
      console.log(err)
      console.log(data.toString());
   });
}

fun();

But when it runs, it throws this error:

{ Error: spawn ExecFileTest ENOENT
at _errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn ExecFileTest',
path: 'ExecFileTest',
spawnargs: ...
}

I have the version of node.js 8.11 installed. I have searched for this error but I have not found anything.

Any suggestions?

    
asked by JGuerra 21.05.2018 в 23:45
source

0 answers