How do I debug “Error: spawn ENOENT” on node.js?

后端 未结 25 3309
轻奢々
轻奢々 2020-11-22 03:00

When I get the following error:

events.js:72
        throw er; // Unhandled \'error\' event
              ^
Error: spawn ENOENT
    at errnoException (chil         


        
25条回答
  •  面向向阳花
    2020-11-22 03:28

    Use require('child_process').exec instead of spawn for a more specific error message!

    for example:

    var exec = require('child_process').exec;
    var commandStr = 'java -jar something.jar';
    
    exec(commandStr, function(error, stdout, stderr) {
      if(error || stderr) console.log(error || stderr);
      else console.log(stdout);
    });
    

提交回复
热议问题