I'm using node-cross-spawn via execa inside a worker thread.
I seem to have found an issue related to #127 that only pops up if you set a custom cwd.
I've traced the error back to this line: https://github.com/moxystudio/node-cross-spawn/blob/master/lib/util/resolveCommand.js#L11
When we're running in a worker thread process.chdir is not undefined. Instead, it's a named function.
console.log(process.chdir);
// [Function: unavailableInWorker] { disabled: true }
Therefore shouldSwitchCwd is true when running in a worker thread with custom cwd.
I can see one reliable way of improving this check:
const { isMainThread } = require('worker_threads');
const shouldSwitchCwd = hasCustomCwd && isMainThread;
Though I'm not sure what would happen to the cwd option and how it would affect things. I'm not very well versed in these matters. These changes do fix the issue for me in any case so I'll make a PR for this change.