Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

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

When I get the following error:*
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:1000:11)
at Process.ChildProcess._handle.onexit (child_process.js:791:34)


*What procedure can I follow to fix it?
by

3 Answers

akshay1995
Replace spawn with node-cross-spawn. For instance like this at the beginning of your app.js:

(function() {
var childProcess = require("child_process");
childProcess.spawn = require('cross-spawn');
})();
RoliMishra
Windows solution: Replace spawn with node-cross-spawn. For instance like this at the beginning of your app.js:

(function() {
var childProcess = require("child_process");
childProcess.spawn = require('cross-spawn');
})();
pankajshivnani123
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});

Login / Signup to Answer the Question.