File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,10 +164,10 @@ function executeUserEntryPoint(main = process.argv[1]) {
164164 if ( ! useESMLoader ) {
165165 // Module._load is the monkey-patchable CJS module loader.
166166 const { Module } = require ( 'internal/modules/cjs/loader' ) ;
167- try {
168- Module . _load ( main , null , true ) ;
169- } catch ( error ) {
170- if ( getOptionValue ( '--experimental-detect-module' ) ) {
167+ if ( getOptionValue ( '--experimental-detect-module' ) ) {
168+ try {
169+ Module . _load ( main , null , true ) ;
170+ } catch ( error ) {
171171 const { cjsRetryAsESMCache } = require ( 'internal/modules/cjs/loader' ) ;
172172 const source = cjsRetryAsESMCache . get ( resolvedMain ) ;
173173 cjsRetryAsESMCache . delete ( resolvedMain ) ;
@@ -176,11 +176,11 @@ function executeUserEntryPoint(main = process.argv[1]) {
176176 if ( ! retryAsESM ) {
177177 const { enrichCJSError } = require ( 'internal/modules/esm/translators' ) ;
178178 enrichCJSError ( error , source , resolvedMain ) ;
179+ throw error ;
179180 }
180181 }
181- if ( ! retryAsESM ) {
182- throw error ;
183- }
182+ } else {
183+ Module . _load ( main , null , true ) ;
184184 }
185185 }
186186
You can’t perform that action at this time.
0 commit comments