Skip to content
Prev Previous commit
Next Next commit
repair error message
  • Loading branch information
mertcanaltin committed Jun 2, 2025
commit ab7ee6e54b93cb71af11099431c34ce302336b6d
9 changes: 2 additions & 7 deletions lib/internal/modules/esm/module_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@
isCommonJSGlobalLikeNotDefinedError(e.message)) {

if (e.message.includes('require is not defined')) {
e.message = [
'ERR_AMBIGUOUS_MODULE_SYNTAX: This file cannot be parsed as either CommonJS or ES Module.',
'- CommonJS error: await is only valid in async functions.',
'- ES Module error: require is not defined in ES module scope.',
'If you meant to use CommonJS, wrap top-level await in async function.',
'If you meant to use ESM, do not use require().',
].join('\n');
e.message =
'ERR_AMBIGUOUS_MODULE_SYNTAX: This file cannot be parsed as either CommonJS or ES Module. CommonJS error: await is only valid in async functions. ES Module error: require is not defined in ES module scope. If you meant to use CommonJS, wrap top-level await in async function. If you meant to use ESM, do not use require().';

Check failure on line 81 in lib/internal/modules/esm/module_job.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 332. Maximum allowed is 120
e.code = 'ERR_AMBIGUOUS_MODULE_SYNTAX';
return;
}
Expand Down
Loading