The above code snippet causes an ERR_AMBIGUOUS_MODULE_SYNTAX error, since module.exports cannot be used (CJS) in an ESM file. However, the error logged to the console, shown below, incorrectly assumes the error stems from the use of a require()
ReferenceError: Cannot determine intended module format because both require() and top-level await are present. If the code is intended to be CommonJS, wrap await in an async function. If the code is intended to be an ES module, replace require() with import.
The above code snippet causes an
ERR_AMBIGUOUS_MODULE_SYNTAXerror, sincemodule.exportscannot be used (CJS) in an ESM file. However, the error logged to the console, shown below, incorrectly assumes the error stems from the use of arequire()