A module is a is code which uses ‘export’ statement.
To solve this problem I use Bun, it’s a runtime and a js bundler. With bun you can use both statements and it takes care about that shit.
You just have to bundle the code (build it in a single file) with a script. And target the correct environment (“node” if you want your code to be executed on the server, browser if you want it to run in the browser)