To run async code in a script, use:
mjs
extensionNODE_OPTIONS='--experimental-json-modules'
Inside package.json
:
"script-name": "NODE_OPTIONS='--experimental-json-modules' && node ./path/to/script.mjs",
Then write any kind of async
code in the top level:
await fs.writeFile("file");