MCPcopy Index your code
hub / github.com/nodejs/node / fixReplRequire

Function fixReplRequire

lib/internal/repl/utils.js:795–809  ·  view source on GitHub ↗
(replModule)

Source from the content-addressed store, hash-verified

793const path = require('path');
794
795function fixReplRequire(replModule) {
796 try {
797 // Hack for require.resolve("./relative") to work properly.
798 replModule.filename = path.resolve('repl');
799 } catch {
800 // path.resolve('repl') fails when the current working directory has been
801 // deleted. Fall back to the directory name of the (absolute) executable
802 // path. It's not really correct but what are the alternatives?
803 const dirname = path.dirname(process.execPath);
804 replModule.filename = path.resolve(dirname, 'repl');
805 }
806
807 // Hack for repl require to work properly with node_modules folders
808 replModule.paths = CJSModule._nodeModulePaths(replModule.filename);
809}
810
811let nextREPLResourceNumber = 1;
812// This prevents v8 code cache from getting confused and using a different

Callers 2

repl.jsFile · 0.85
completion.jsFile · 0.85

Calls 1

resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…