title: Node Error spawn /bin/sh ENOENT on remote server
body: <p>Okay I know there are multiple questions regarding this topic, I read most of them and nothing helped.</p>
  
  <p>I am trying to have a node server run a python script periodically. For this I've got the following code:</p>
  
  <pre><code>const
      { exec } = require('child_process');
  const fs = require('fs');
  
  
  let config = [
  {
      "title": "My Python Script",
      "description": "A script that can scrape website data",
      "command": "python3 collect_data.py",
      "dir": "../file_folder",
      "minutesBetweenExecution": 60
  }
  ];
  
  
  
  const intervals = [];
  
  
  function startCronjobs() {
      while (intervals.length &gt; 0) {
          clearInterval(intervals.pop());
      }
  
      console.log("Starting cronjobs...")
  
      for (let i = 0; i &lt; config.length; i++) {
          const cron = config[i];
          const func = () =&gt; {
              exec(cron.command, { cwd: cron.dir, timeout: 40 * 60000 }, (err, stdout, stderr) =&gt; {
                  if (err) {
                      // node couldn't execute the command
                      console.error('Command could not be executed. Error: ', err, ' cron entry: ', cron.title);
                      return;
                  }
                  console.log('Output after ', cron.title);
                  // the *entire* stdout and stderr (buffered)
                  console.log(`stdout: ${stdout}`);
                  console.log(`stderr: ${stderr}`);
              });
          };
  
          intervals.push(setInterval(func, parseInt(cron.minutesBetweenExecution) * 60000));
          console.log('Started Cronjob', cron.title);
          func();
      }
  }
  
  startCronjobs();
  </code></pre>
  
  <p>As you can see, the script just runs exec with a specified command and working directory.
  Yet, when trying to execute <code>func()</code> node throws the error specified above.</p>
  
  <p>Stuff I've tried to fix this:</p>
  
  <ul>
  <li>Use an absolute path for the working directory</li>
  <li>checked if <code>python3</code> is in PATH: <code>which python3</code> returns <code>/usr/bin/python3</code></li>
  <li>run the node server with <code>sudo</code></li>
  <li>debug logged <code>process.env.PATH</code>: <code>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games</code></li>
  </ul>
  
  <p>The weird thing about this is: When I am trying to run this on my local linux machine, it works perfectly. On my remote server, however, it does not. What am I missing?</p>