title: Issue running puppeteer in github actions
body: <p>Everything works fine locally, but when I try to run my script using puppeteer in github action, I get this:</p>
  <pre><code>file:///dist/index.js:49412
      const puppeteerRootDirectory = pkg_dir_1.default.sync(__dirname);
                                                            ^
  
  ReferenceError: __dirname is not defined in ES module scope
  This file is being treated as an ES module because it has a '.js' file extension and '/dist/package.json' contains &quot;type&quot;: &quot;module&quot;. To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
  </code></pre>
  <p>I've tried defining the <code>__dirname</code> before importing puppeteer but haven't had any luck. e.g.</p>
  <pre><code>import {dirname} from &quot;path&quot;;
  globalThis.__dirname = dirname(import.meta.url);
  import puppeteer from &quot;puppeteer&quot;;
  </code></pre>
  <p>EDIT:</p>
  <p>This appears to be an issue with compiling via ncc. I can repro locally when I run <code>ncc run [my script]</code>. I've looked into how to define __dirname for modules but am still running into issues. I tried something like <a href="https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-when-using-the-experimental-modules-flag">this</a> and adding it at the top of my script before my import statement but it doesn't make a difference. Is there anywhere I can add it that it would be recognized by puppeteer?</p>