Skip to content
Prev Previous commit
lint
  • Loading branch information
mertcanaltin committed Jun 24, 2025
commit ad40103a0ee10821c40686e48469b4ab389b8325
10 changes: 5 additions & 5 deletions lib/internal/modules/esm/module_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ const explainCommonJSGlobalLikeNotDefinedError = (e, url, hasTopLevelAwait) => {
if (e?.name === 'ReferenceError' &&
isCommonJSGlobalLikeNotDefinedError(e.message)) {

if (hasTopLevelAwait) {
e.message = `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.`;
e.code = 'ERR_AMBIGUOUS_MODULE_SYNTAX';
return;
}
if (hasTopLevelAwait) {
e.message = `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.`;
e.code = 'ERR_AMBIGUOUS_MODULE_SYNTAX';
return;
}

e.message += ' in ES module scope';

Expand Down