title: Async function not awaiting the result of child process in Node.js
body: <p>Javascript/Node beginner here.</p>
  <p>I've consulted several posts (<a href="https://stackoverflow.com/questions/47629756/how-can-i-get-the-returned-value-from-the-child-process-exec-in-javascript">Link 1</a>, <a href="https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call">Link 2</a>, <a href="https://stackoverflow.com/questions/4443597/node-js-execute-system-command-synchronously">Link 3</a>) but I am getting an error on my following Node.js code:</p>
  <pre class="lang-js prettyprint-override"><code>const execFile = require('child_process').execFile;
  
  async function execute(){
    let result = await sh();
    console.log(&quot;RESULT: &quot; + result);
  }
  
  async function sh(){
    execFile('./demo-files/demo.sh', ['1st', '2nd', '3rd'], 
    function(err, data){
      let returnValue;
      if(err){
        returnValue = &quot;ERROR:\n&quot; + err;
      }
      else {
        returnValue = data.toString();
      }
      console.log(&quot;return value in fxn: &quot; + returnValue);
      return returnValue;
    });
  }
  
  execute();
  </code></pre>
  <p>The console output:</p>
  <pre class="lang-sh prettyprint-override"><code>RESULT: undefined
  return value in fxn: 2nd
  </code></pre>
  <p>Why does my <code>await</code> not wait for the result of <code>sh()</code>? I expected it to return the value &quot;2nd&quot;.</p>
  <p>(The bash script is inconsequential; it's just <code>echo $2</code>)</p>