facebook/docusaurus · error
File "${relativeFilePath}" does not exist in any of these fo
Error message
File "${relativeFilePath}" does not exist in any of these folders:
- ${folderPaths.join('\n- ')} What it means
Thrown by getFolderContainingFile(), the fail-fast counterpart to findFolderContainingFile(). After scanning each provided folder path for the given relative file, if none contains it the function rejects with a list of every folder searched. The docstring explicitly says callers should use this only when they already know the file exists (e.g. it was discovered via a glob) and just need to resolve which localized folder it lives in.
Source
Thrown at packages/docusaurus-utils/src/dataFileUtils.ts:116
* Fail-fast alternative to `findFolderContainingFile`.
*
* @param folderPaths a list of absolute paths.
* @param relativeFilePath file path relative to each `folderPaths`.
* @returns the first folder path in which the file exists.
* @throws Throws if no file can be found. You should use this method only when
* you actually know the file exists (e.g. when the `relativeFilePath` is read
* with a glob and you are just trying to localize it)
*/
export async function getFolderContainingFile(
folderPaths: string[],
relativeFilePath: string,
): Promise<string> {
const maybeFolderPath = await findFolderContainingFile(
folderPaths,
relativeFilePath,
);
if (!maybeFolderPath) {
throw new Error(
`File "${relativeFilePath}" does not exist in any of these folders:
- ${folderPaths.join('\n- ')}`,
);
}
return maybeFolderPath;
}
View on GitHub (pinned to 3f483e80e3)
Solutions
- Compare the relativeFilePath in the error against the actual file on disk — check for case sensitivity, leading slashes, and path separators.
- Verify every folder listed in the error is one you expect to contain the file; add the missing folder to folderPaths if applicable.
- If you are not certain the file exists, switch to findFolderContainingFile() (which returns undefined) and handle the absence explicitly instead of relying on this fail-fast variant.
- If the file was removed mid-build, restore it or re-run the build after cleaning stale glob caches.
Example fix
// before — caller assumes the file always exists const folder = await getFolderContainingFile(folders, relPath); // after — caller tolerates absence when appropriate const folder = await findFolderContainingFile(folders, relPath); if (!folder) return undefined;
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs-extra';
import path from 'path';
async function everyFileExists(folderPaths: string[], relativeFilePath: string): Promise<boolean> {
return (await Promise.all(folderPaths.map(d => fs.pathExists(path.join(d, relativeFilePath))))).some(Boolean);
}
if (!(await everyFileExists(folders, relPath))) {
// use findFolderContainingFile and handle absence instead of getFolderContainingFile
} Try / catch
try {
await getFolderContainingFile(folderPaths, relativeFilePath);
} catch (err) {
if (err instanceof Error && err.message.startsWith('File "') && err.message.includes('does not exist')) {
// log which folders were searched and skip or fail gracefully
}
throw err;
} Prevention
- Prefer findFolderContainingFile (returns undefined) when existence is not guaranteed.
- Use getFolderContainingFile only for files you obtained from a glob and know exist.
- Normalize path separators before passing relativeFilePath on cross-platform builds.
When it happens
Trigger: Passing a relativeFilePath that does not exist under any of the folderPaths. This typically follows a glob that returned a filename but the file was removed between the glob and the resolution, or the folderPaths list is incomplete (e.g. missing the localized content path for the current locale).
Common situations: A race where a file is deleted or renamed during a build. Misconfigured i18n where the localized folder path is wrong, so the file is searched only in a base path that does not contain the localized variant. A plugin bug passing a path with a leading slash or wrong separator that never matches any folder.
Related errors
- No tags file '${relativeFilePath}' could be found in any of
- Error while attempting to extract Docusaurus translations fr
- Multiple docs sidebar items produce the same translation key
- Please make sure all theme translations are static! Some war
- Can't find locale config for locale ${logger.code(localeToLo
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/0bc73b4ebd24ee8d.
Report an issue: GitHub.