- Version: v7.6.0
- Platform: Darwin Pecorino.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
When a cwd is passed to child_process.spawn() that does not exist, node just reports ENOENT:
const spawn = require("child_process").spawn
spawn(process.execPath, { cwd: "/does/not/exist" });
> Error: spawn /usr/local/bin/node ENOENT
at exports._errnoException (util.js:1028:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
This error message is very confusing because it reads like /usr/local/bin/node does not exist. It took me several hours to debug this issue, including serious doubts in my sanity 😁.
Do you think it is feasible to check the cwd before spawning the process, or is there a use-case/is it possible to spawn a process with a non-existent cwd? If it's not feasible, would it be an option to include the cwd in the error message to give a slight hint in the right direction?
When a cwd is passed to
child_process.spawn()that does not exist, node just reportsENOENT:This error message is very confusing because it reads like
/usr/local/bin/nodedoes not exist. It took me several hours to debug this issue, including serious doubts in my sanity 😁.Do you think it is feasible to check the cwd before spawning the process, or is there a use-case/is it possible to spawn a process with a non-existent cwd? If it's not feasible, would it be an option to include the cwd in the error message to give a slight hint in the right direction?