{"record":{"id":"0bc73b4ebd24ee8d","repo":"facebook/docusaurus","slug":"file-relativefilepath-does-not-exist-in-any-o","errorCode":null,"errorMessage":"File \"${relativeFilePath}\" does not exist in any of these folders:\n- ${folderPaths.join('\\n- ')}","messagePattern":"File \"(.+?)\" does not exist in any of these folders:\n- (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-utils/src/dataFileUtils.ts","lineNumber":116,"sourceCode":" * Fail-fast alternative to `findFolderContainingFile`.\n *\n * @param folderPaths a list of absolute paths.\n * @param relativeFilePath file path relative to each `folderPaths`.\n * @returns the first folder path in which the file exists.\n * @throws Throws if no file can be found. You should use this method only when\n * you actually know the file exists (e.g. when the `relativeFilePath` is read\n * with a glob and you are just trying to localize it)\n */\nexport async function getFolderContainingFile(\n  folderPaths: string[],\n  relativeFilePath: string,\n): Promise<string> {\n  const maybeFolderPath = await findFolderContainingFile(\n    folderPaths,\n    relativeFilePath,\n  );\n  if (!maybeFolderPath) {\n    throw new Error(\n      `File \"${relativeFilePath}\" does not exist in any of these folders:\n- ${folderPaths.join('\\n- ')}`,\n    );\n  }\n  return maybeFolderPath;\n}\n","sourceCodeStart":98,"sourceCodeEnd":123,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-utils/src/dataFileUtils.ts#L98-L123","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before — caller assumes the file always exists\nconst folder = await getFolderContainingFile(folders, relPath);\n\n// after — caller tolerates absence when appropriate\nconst folder = await findFolderContainingFile(folders, relPath);\nif (!folder) return undefined;","handlingStrategy":"validation","validationCode":"import fs from 'fs-extra';\nimport path from 'path';\n\nasync function everyFileExists(folderPaths: string[], relativeFilePath: string): Promise<boolean> {\n  return (await Promise.all(folderPaths.map(d => fs.pathExists(path.join(d, relativeFilePath))))).some(Boolean);\n}\n\nif (!(await everyFileExists(folders, relPath))) {\n  // use findFolderContainingFile and handle absence instead of getFolderContainingFile\n}","typeGuard":null,"tryCatchPattern":"try {\n  await getFolderContainingFile(folderPaths, relativeFilePath);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('File \"') && err.message.includes('does not exist')) {\n    // log which folders were searched and skip or fail gracefully\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["file-not-found","path","i18n","fail-fast"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}