Lines Matching refs:filename

182  * @param {string} filename Absolute path to the file
184 function stat(filename) {
185 filename = path.toNamespacedPath(filename);
187 const result = statCache.get(filename);
190 const result = internalModuleStat(filename);
192 // Only set cache when `internalModuleStat(filename)` succeeds.
193 statCache.set(filename, result);
225 * @param {string} filename Absolute path of the module
227 function reportModuleToWatchMode(filename) {
229 process.send({ 'watch:require': [filename] });
257 this.filename = null;
277 /** @type {Record<string, (module: Module, filename: string) => void>} */
435 const filename = path.resolve(requestPath, pkg);
436 let actual = tryFile(filename, isMain) ||
437 tryExtensions(filename, exts, isMain) ||
438 tryExtensions(path.resolve(filename, 'index'), exts, isMain);
444 `Cannot find module '${filename}'. ` +
482 * @param {string} basePath The path and filename without extension
488 const filename = tryFile(basePath + exts[i], isMain);
490 if (filename) {
491 return filename;
499 * @param {string} filename The filename to find the longest registered extension for.
501 function findLongestRegisteredExtension(filename) {
502 const name = path.basename(filename);
522 if (parent.filename) {
523 return parent.filename;
671 let filename;
678 filename = path.resolve(basePath);
680 filename = toRealPath(basePath);
691 filename = path.resolve(basePath);
693 filename = toRealPath(basePath);
697 if (!filename) {
702 filename = tryExtensions(basePath, exts, isMain);
706 if (!filename && rc === 1) { // Directory.
711 filename = tryPackage(basePath, exts, isMain, request);
714 if (filename) {
715 Module._pathCache[cacheKey] = filename;
716 return filename;
861 // In REPL, parent.filename is null.
862 if (!parent || !parent.id || !parent.filename) {
864 // from realpath(__filename) but in REPL there is no filename
873 const parentDir = [path.dirname(parent.filename)];
954 const filename = relativeResolveCache[relResolveCacheIdentifier];
955 reportModuleToWatchMode(filename);
956 if (filename !== undefined) {
957 const cachedModule = Module._cache[filename];
981 const filename = Module._resolveFilename(request, parent, isMain);
982 const cachedModule = Module._cache[filename];
996 if (BuiltinModule.canBeRequiredWithoutScheme(filename)) {
997 const mod = loadBuiltinModule(filename, request);
1002 const module = cachedModule || new Module(filename, parent);
1010 reportModuleToWatchMode(filename);
1012 Module._cache[filename] = module;
1014 relativeResolveCache[relResolveCacheIdentifier] = filename;
1019 module.load(filename);
1023 delete Module._cache[filename];
1096 if (request[0] === '#' && (parent?.filename || parent?.id === '<repl>')) {
1097 const parentPath = parent?.filename ?? process.cwd() + path.sep;
1125 // Look up the filename first, since that's the cache key.
1126 const filename = Module._findPath(request, paths, isMain);
1127 if (filename) { return filename; }
1132 ArrayPrototypePush(requireStack, cursor.filename || cursor.id);
1160 const filename = fileURLToPath(resolved);
1161 const actual = tryFile(filename);
1165 const err = createEsmNotFoundErr(filename,
1188 * @param {string} filename The `require` specifier
1190 Module.prototype.load = function(filename) {
1191 debug('load %j for module %j', filename, this.id);
1194 this.filename = filename;
1195 this.paths = Module._nodeModulePaths(path.dirname(filename));
1197 const extension = findLongestRegisteredExtension(filename);
1199 if (StringPrototypeEndsWith(filename, '.mjs') && !Module._extensions['.mjs']) {
1200 throw new ERR_REQUIRE_ESM(filename, true);
1203 Module._extensions[extension](this, filename);
1248 * @param {string} filename The name of the file being loaded
1252 function wrapSafe(filename, content, cjsModuleInstance) {
1253 const hostDefinedOptionId = Symbol(`cjs:${filename}`);
1256 return cascadedLoader.import(specifier, normalizeReferrerURL(filename),
1263 filename, // filename
1275 maybeCacheSourceMap(filename, content, this, false, undefined, script.sourceMapURL);
1285 filename, // filename
1299 maybeCacheSourceMap(filename, content, this, false, undefined, result.sourceMapURL);
1316 * @param {string} filename The file path of the module
1318 Module.prototype._compile = function(content, filename) {
1323 moduleURL = pathToFileURL(filename);
1328 const compiledWrapper = wrapSafe(filename, content, this);
1333 // We enter the repl if we're not given a filename argument.
1348 if (resolvedArgv && !hasPausedEntry && filename === resolvedArgv) {
1353 const dirname = path.dirname(filename);
1362 require, module, filename, dirname);
1365 [exports, require, module, filename, dirname]);
1375 * @param {string} filename The file path of the module
1377 Module._extensions['.js'] = function(module, filename) {
1385 content = fs.readFileSync(filename, 'utf8');
1387 if (StringPrototypeEndsWith(filename, '.js')) {
1388 const pkg = packageJsonReader.readPackageScope(filename) || { __proto__: null };
1392 const parentPath = parent?.filename;
1395 const err = new ERR_REQUIRE_ESM(filename, usesEsm, parentPath,
1422 module._compile(content, filename);
1428 * @param {string} filename The file path of the module
1430 Module._extensions['.json'] = function(module, filename) {
1431 const content = fs.readFileSync(filename, 'utf8');
1435 const moduleURL = pathToFileURL(filename);
1442 err.message = filename + ': ' + err.message;
1450 * @param {string} filename The file path of the module
1452 Module._extensions['.node'] = function(module, filename) {
1455 const content = fs.readFileSync(filename);
1456 const moduleURL = pathToFileURL(filename);
1460 return process.dlopen(module, path.toNamespacedPath(filename));
1465 * @param {string} filename The path to the module
1467 function createRequireFromPath(filename) {
1468 // Allow a directory to be passed as the filename
1470 StringPrototypeEndsWith(filename, '/') ||
1471 (isWindows && StringPrototypeEndsWith(filename, '\\'));
1474 path.join(filename, 'noop.js') :
1475 filename;
1478 m.filename = proxyPath;
1489 * @param {string | URL} filename The path or URL to the module context for this `require`
1490 * @throws {ERR_INVALID_ARG_VALUE} If `filename` is not a string or URL, or if it is a relative path that cannot be
1493 function createRequire(filename) {
1496 if (isURL(filename) ||
1497 (typeof filename === 'string' && !path.isAbsolute(filename))) {
1499 filepath = fileURLToPath(filename);
1501 throw new ERR_INVALID_ARG_VALUE('filename', filename,
1504 } else if (typeof filename !== 'string') {
1505 throw new ERR_INVALID_ARG_VALUE('filename', filename, createRequireError);
1507 filepath = filename;