Skip to content

Commit

Permalink
fixup! module: detect ESM syntax by trying to recompile as SourceText…
Browse files Browse the repository at this point in the history
…Module
  • Loading branch information
joyeecheung committed Apr 11, 2024
1 parent 9bbb657 commit dc9f175
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/modules/run_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const {
ObjectGetPrototypeOf,
SyntaxErrorPrototype,
StringPrototypeEndsWith,
SyntaxErrorPrototype,
globalThis,
} = primordials;

Expand Down Expand Up @@ -174,7 +174,7 @@ function executeUserEntryPoint(main = process.argv[1]) {
// Module._load is the monkey-patchable CJS module loader.
Module._load(main, null, true);
} catch (error) {
if (ObjectGetPrototypeOf(error) === SyntaxErrorPrototype) {
if (error != null && ObjectGetPrototypeOf(error) === SyntaxErrorPrototype) {
const { shouldRetryAsESM } = internalBinding('contextify');
const mainPath = resolvedMain || main;
mainURL = pathToFileURL(mainPath).href;
Expand Down

0 comments on commit dc9f175

Please sign in to comment.