childProcess.spawn fails when `env` is specified childProcess.spawn fails when `env` is specified shell shell

childProcess.spawn fails when `env` is specified


You can override the PORT even without passing env, using /usr/bin/env

const child = childProcess.spawn('env', ['PORT=4545', 'npm', 'run', taskName], {  cwd: `${parentPath}/${projectId}`,});

If you haven't checked process.env, make sure you override PATH with a known-good value.

const child = childProcess.spawn('npm', ['run', taskName], {  cwd: `${parentPath}/${projectId}`,  env: {    PATH: '/bin:/usr/bin:/usr/local/bin',    PORT: 4545,  }});