events.js:72
throw er; // Unhandled \'error\' event
^
Error: spawn ENOENT
at errnoException (chil
env
option?Then look at this answer.
I was trying to spawn a node process and TIL that you should spread the existing environment variables when you spawn else you'll loose the PATH
environment variable and possibly other important ones.
This was the fix for me:
const nodeProcess = spawn('node', ['--help'], {
env: {
// by default, spawn uses `process.env` for the value of `env`
// you can _add_ to this behavior, by spreading `process.env`
...process.env,
OTHER_ENV_VARIABLE: 'test',
}
});