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

后端 未结 25 3307
轻奢々
轻奢々 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:36

    in windows, simply adding shell: true option solved my problem:

    incorrect:

    const { spawn } = require('child_process');
    const child = spawn('dir');
    

    correct:

    const { spawn } = require('child_process');
    const child = spawn('dir', [], {shell: true});
    

提交回复
热议问题