angular/angular-cli · error · Error
Unknown file requested: ${path}
Error message
Unknown file requested: ${path} What it means
In ivy-extract-loader, a minimal virtual filesystem object is created that only knows two paths: the synthesized extraction input file (`filename`) and its source map (`filename + '.map'`). Any other path passed to readFile throws 'Unknown file requested'. This guards consumers of the extractor against accidentally reading files this virtual FS cannot serve.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/extract-i18n/ivy-extract-loader.ts:95
let filename = loaderContext.resourcePath;
const mapObject =
typeof map === 'string' ? (JSON.parse(map) as Exclude<LoaderSourceMap, string>) : map;
if (mapObject?.file) {
// The extractor's internal sourcemap handling expects the filenames to match
filename = nodePath.join(loaderContext.context, mapObject.file);
}
// Setup a virtual file system instance for the extractor
// * MessageExtractor itself uses readFile, relative and resolve
// * Internal SourceFileLoader (sourcemap support) uses dirname, exists, readFile, and resolve
const filesystem = {
readFile(path: string): string {
if (path === filename) {
return content;
} else if (path === filename + '.map') {
return typeof map === 'string' ? map : JSON.stringify(map);
} else {
throw new Error('Unknown file requested: ' + path);
}
},
relative(from: string, to: string): string {
return nodePath.relative(from, to);
},
resolve(...paths: string[]): string {
return nodePath.resolve(...paths);
},
exists(path: string): boolean {
return path === filename || path === filename + '.map';
},
dirname(path: string): string {
return nodePath.dirname(path);
},
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const extractor = new MessageExtractor(filesystem as any, logger, {View on GitHub (pinned to bb72145f9a)
Solutions
- Check the exact path being requested vs. the loader's `filename` (log both; often it's an absolute vs relative path mismatch).
- Update @angular/localize to a version compatible with your Angular CLI, where the extractor only requests the known files.
- If you own the loader code, normalize the incoming path (path.resolve/isAbsolute) before comparison.
- Ensure no plugin or custom extractor configuration causes reads of extra source files.
Example fix
// before
readFile(path: string): string {
if (path === filename) { return content; }
...
}
// after
readFile(path: string): string {
const resolved = nodePath.resolve(path);
if (resolved === nodePath.resolve(filename)) { return content; }
if (resolved === nodePath.resolve(filename + '.map')) { ... }
...
} Defensive patterns
Strategy: type-guard
Type guard
function isLoaderKnownPath(path: string, filename: string): boolean {
return path === filename || path === filename + '.map';
} Try / catch
try {
return loader.readFile(path);
} catch (e) {
if (e.message.startsWith('Unknown file requested')) {
return '';
}
throw e;
} Prevention
- Only request the exact filename/filename+'.map' strings from the loader.
- Normalize paths (resolve/normalize) before comparing.
- Pin @angular/localize to a version compatible with your CLI.
- Avoid plugins that probe the virtual FS for extra files.
When it happens
Trigger: The MessageExtractor (or other consumer) calls readFile with any path other than the exact `filename` or `filename + '.map'` strings — e.g. requesting an absolute variant of the filename, a sibling chunk, or a differently-cased path.
Common situations: Tooling inside @angular/localize/tools that resolves the input path to an absolute path before reading, mismatching the exact string comparison; custom extractors or plugins probing for additional files; localize version changes that read auxiliary files the loader does not provide.
Related errors
- Unknown file requested: ${requestedPath}
- TestProjectHost must be initialized before being used.
- Could not find server output directory: ${outputPath}.
- Unable to load message extractor. Please ensure '@angular/lo
- Could not find package.json
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/d1f4116b307ecf03.
Report an issue: GitHub.