Skip to content

Commit dc9f175

Browse files
committed
fixup! module: detect ESM syntax by trying to recompile as SourceTextModule
1 parent 9bbb657 commit dc9f175

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/internal/modules/run_main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
const {
44
ObjectGetPrototypeOf,
5-
SyntaxErrorPrototype,
65
StringPrototypeEndsWith,
6+
SyntaxErrorPrototype,
77
globalThis,
88
} = primordials;
99

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

0 commit comments

Comments
 (0)