microsoft/TypeScript · error · Error
Expected ${inputDir} to be a directory
Error message
Expected ${inputDir} to be a directory What it means
produceLKG.mjs copies each localization directory from `source` to `dest`. For every name in localizationDirectories it stats the source path and throws if it isn't a directory, so a partial localization build can't be copied into the LKG.
Source
Thrown at scripts/produceLKG.mjs:34
console.log(`Building LKG from ${source} to ${dest}`);
await fs.promises.rm(dest, { recursive: true, force: true });
await fs.promises.mkdir(dest, { recursive: true });
await copyLibFiles();
await copyLocalizedDiagnostics();
await copyTypesMap();
await copyScriptOutputs();
await copyDeclarationOutputs();
await writeGitAttributes();
}
async function copyLibFiles() {
await copyFilesWithGlob("lib?(.*).d.ts");
}
async function copyLocalizedDiagnostics() {
for (const d of localizationDirectories) {
const inputDir = path.join(source, d);
if (!fs.statSync(inputDir).isDirectory()) throw new Error(`Expected ${inputDir} to be a directory`);
const outputDir = path.join(dest, d);
await fs.promises.mkdir(outputDir, { recursive: true });
for (const f of await fs.promises.readdir(inputDir)) {
const inputFile = path.join(inputDir, f);
if (!fs.statSync(inputFile).isFile()) throw new Error(`Expected ${inputFile} to be a file`);
const outputFile = path.join(outputDir, f);
await fs.promises.copyFile(inputFile, outputFile);
}
}
}
async function copyTypesMap() {
await copyFromBuiltLocal("typesMap.json"); // Cannot accommodate copyright header
}
async function copyScriptOutputs() {
await copyFromBuiltLocal("tsc.js");
await copyFromBuiltLocal("_tsc.js");
View on GitHub (pinned to b465fdbfe1)
Solutions
- Run the full localization build before invoking produceLKG.
- Inspect the path in the error message and ensure it exists as a directory.
- Clean `built/` (`git clean -fdx built/`) and rebuild end-to-end.
Defensive patterns
Strategy: validation
Validate before calling
import fs from "fs";
for (const d of localizationDirectories) {
const p = path.join(source, d);
const st = fs.statSync(p);
if (!st.isDirectory()) throw new Error(`Expected ${p} to be a directory`);
} Prevention
- Run the localization build before produceLKG.
- Clean built/ before producing an LKG from a known state.
When it happens
Trigger: A name in localizationDirectories resolves to a non-existent path or a file rather than a directory under `source`.
Common situations: Skipping the localize/L10n build step; a stray file where a directory is expected; previous build left inconsistent state.
Related errors
- Cannot replace the LKG unless all built targets are present
- Expected ${inputFile} to be a file
- LKG cannot be created when --bundle=false
- Diagnostic code ${code} appears more than once.
- tsserverlibrary requires CommonJS; use typescript.js instead
AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12).
Data as JSON: /api/errors/5d56e9767d5e3a49.
Report an issue: GitHub.