diff --git a/graal-nodejs/lib/internal/modules/run_main.js b/graal-nodejs/lib/internal/modules/run_main.js index e4b971d0c4e..42a0b6af062 100644 --- a/graal-nodejs/lib/internal/modules/run_main.js +++ b/graal-nodejs/lib/internal/modules/run_main.js @@ -4,8 +4,7 @@ const { ObjectCreate, StringPrototypeEndsWith, } = primordials; -const CJSLoader = require('internal/modules/cjs/loader'); -const { Module, toRealPath, readPackageScope } = CJSLoader; + const { getOptionValue } = require('internal/options'); const path = require('path'); @@ -13,6 +12,7 @@ function resolveMainPath(main) { // Note extension resolution for the main entry point can be deprecated in a // future major. // Module._findPath is monkey-patchable here. + const { Module, toRealPath } = require('internal/modules/cjs/loader'); let mainPath = Module._findPath(path.resolve(main), null, true); if (!mainPath) return; @@ -41,6 +41,7 @@ function shouldUseESMLoader(mainPath) { getOptionValue('--experimental-specifier-resolution'); if (esModuleSpecifierResolution === 'node') return true; + const { readPackageScope } = require('internal/modules/cjs/loader'); // Determine the module format of the main if (mainPath && StringPrototypeEndsWith(mainPath, '.mjs')) return true; @@ -83,6 +84,7 @@ function executeUserEntryPoint(main = process.argv[1]) { runMainESM(resolvedMain || main); } else { // Module._load is the monkey-patchable CJS module loader. + const { Module } = require('internal/modules/cjs/loader'); Module._load(main, null, true); } } diff --git a/graal-nodejs/test/fixtures/errors/force_colors.snapshot b/graal-nodejs/test/fixtures/errors/force_colors.snapshot index 4c33acbc2d5..acd77450f02 100644 --- a/graal-nodejs/test/fixtures/errors/force_colors.snapshot +++ b/graal-nodejs/test/fixtures/errors/force_colors.snapshot @@ -8,7 +8,7 @@ Error: Should include grayed stack trace  at Module._extensions..js (node:internal*modules*cjs*loader:1310:10)  at Module.load (node:internal*modules*cjs*loader:1119:32)  at Module._load (node:internal*modules*cjs*loader:960:12) - at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:86:12) + at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:88:12)  at node:internal*main*run_main_module:23:47 Node.js *