title: SyntaxError: await is only valid in async function
body: <p>I am trying to write a simple node.js program that will take in a json5 file and convert it to a json file. I have found this <a href="https://www.npmjs.com/package/any-json" rel="nofollow noreferrer">https://www.npmjs.com/package/any-json</a> which I believe will be useful. </p>
  
  <p>This is the code I currently have...</p>
  
  <pre><code>const anyJson = require("any-json");
  
  const str = await anyJson.encode({/* test comment */ "foo": "bar"}, 'json');
  </code></pre>
  
  <p>however it gives me this error...</p>
  
  <pre><code>const str = await anyJson.encode({/* test comment */ "foo": "bar"}, 'json'); 
  </code></pre>
  
  <p>(^^^^^ under the await)  </p>
  
  <pre><code>SyntaxError: await is only valid in async function
  </code></pre>
  
  <blockquote>
    <p>Note: This exact code works in the npm runkit</p>
  </blockquote>