angular/angular-cli · error · Error
Unknown file requested: ${requestedPath}
Error message
Unknown file requested: ${requestedPath} What it means
The extract-i18n application builder exposes a virtual filesystem-like helper `readFile` that resolves translation source files by path. Files can come from memory (in-memory build outputs, decoded via TextDecoder) or from disk (read with readFileSync). If the requested path resolves to neither and content remains undefined, it throws 'Unknown file requested' to signal that the path is not a known artifact of the extraction pipeline.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/extract-i18n/application-extraction.ts:117
const fileMap = new Map(files.map((file) => [file.path, file]));
const textDecoder = new TextDecoder();
// 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 {
// Output files are stored as relative to the workspace root
const requestedPath = nodePath.relative(context.workspaceRoot, path);
const file = fileMap.get(requestedPath);
let content;
if (file?.origin === 'memory') {
content = textDecoder.decode(file.contents);
} else if (file?.origin === 'disk') {
content = readFileSync(file.inputPath, 'utf-8');
}
if (content === undefined) {
throw new Error('Unknown file requested: ' + requestedPath);
}
return content;
},
relative(from: string, to: string): string {
return nodePath.relative(from, to);
},
resolve(...paths: string[]): string {
return nodePath.resolve(...paths);
},
exists(path: string): boolean {
// Output files are stored as relative to the workspace root
const requestedPath = nodePath.relative(context.workspaceRoot, path);
return fileMap.has(requestedPath);
},
dirname(path: string): string {
return nodePath.dirname(path);View on GitHub (pinned to bb72145f9a)
Solutions
- Verify the exact path string matches the output file name produced by the application build (check outputPath/emitted files).
- Ensure the file exists on disk at the expected location before extraction, or that the build actually emitted it into memory.
- Clear the Angular CLI cache (ng cache clean or delete .angular/cache) to drop stale file records.
- Update any custom tooling that hardcodes paths to derive the path from the builder output instead.
Example fix
// before
const content = fs.readFile('/dist/app/browser/old-bundle.js');
// after
const emitted = outputFiles.find((f) => f.path.endsWith('.js'));
const content = fs.readFile(emitted.path); Defensive patterns
Strategy: validation
Validate before calling
const emitted = outputFiles.find((f) => f.path === requestedPath);
if (!emitted && !fs.existsSync(requestedPath)) {
throw new Error(`File not produced by build: ${requestedPath}`);
} Type guard
function isKnownArtifact(path: string, outputFiles: { path: string }[]): boolean {
return outputFiles.some((f) => f.path === path) || fs.existsSync(path);
} Try / catch
try {
const content = fs.readFile(requestedPath);
} catch (e) {
if (e.message.startsWith('Unknown file requested')) {
console.warn(`Skipping unknown artifact: ${requestedPath}`);
} else throw e;
} Prevention
- Derive file paths from builder output, never hardcode them.
- Log available output paths when a lookup fails.
- Clear .angular/cache when seeing stale file records.
- Keep build output naming options consistent between build and extraction steps.
When it happens
Trigger: Calling the builder's readFile helper with a path that was never produced by the application build or extraction pipeline — e.g. a stale/incorrect requestedPath, a file emitted under a different output name, or a path referencing a file excluded from the build so neither the memory-origin nor disk-origin branch supplies content.
Common situations: Custom scripts or plugins that consume extract-i18n internals and pass hardcoded paths; output file renamed via build options (outputPath/outputs changes) while code still requests the old name; incremental-cache corruption where a cached file record is missing its origin.
Related errors
- Could not find server output directory: ${outputPath}.
- Unknown file requested: ${path}
- Error(s) occurred while extracting routes:\n${errors.map((er
- Could not find the main bundle.
- Webpack stats build result is required.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/c5dec0b6e31a43e6.
Report an issue: GitHub.