{"record":{"id":"fe3331a21856f20d","repo":"facebook/flow","slug":"pkg-flow-bin-not-found-in-dirstocheck-join","errorCode":null,"errorMessage":"Pkg flow-bin not found in ${dirsToCheck.join(', ')}","messagePattern":"Pkg flow-bin not found in (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/flow-for-vscode/src/utils/getFlowPath.ts","lineNumber":97,"sourceCode":"  workspaceRoot: string,\n  logger: Logger,\n): Promise<string> {\n  const dirsToCheck = [\n    // a) check in flowconfig dir\n    flowconfigDir,\n    // b) check in workspaceRoot (ignore if flowconfigDir and workspaceRoot same)\n    flowconfigDir !== workspaceRoot ? workspaceRoot : null,\n  ].filter((v) => v != null);\n\n  for (let i = 0; i < dirsToCheck.length; i += 1) {\n    // eslint-disable-next-line no-await-in-loop\n    const flowPath = await getFlowBinPath(dirsToCheck[i], logger);\n    if (flowPath) {\n      return flowPath;\n    }\n  }\n\n  throw new Error(`Pkg flow-bin not found in ${dirsToCheck.join(', ')}`);\n}\n\nasync function getCommandFlowPath(\n  command: string,\n  logger: Logger,\n): Promise<string> {\n  logger.trace(`Checking '${command}'`);\n  const flowPath = await which(command);\n  if (!flowPath) {\n    throw new Error(`'${command}' not found`);\n  }\n  return flowPath;\n}\n\nfunction getBundledFlowPath(): string {\n  const extensionPath = getExtensionPath();\n  // NOTE: 'vsce package' never bundles node_modules/.bin folder\n  // (see: https://github.com/Microsoft/vscode/issues/53916)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/facebook/flow/blob/d1341dac899a79c027762f6b423d896045287620/packages/flow-for-vscode/src/utils/getFlowPath.ts#L79-L115","documentation":"With the useNPMPackagedFlow strategy, the extension searches for the flow-bin npm package in the .flowconfig directory and then the workspace root. If neither directory yields a usable flow binary, it throws listing the directories searched.","triggerScenarios":"`flow.useNPMPackagedFlow` is enabled and neither <flowconfigDir> nor <workspaceRoot> contains node_modules/flow-bin with a resolvable binary.","commonSituations":"flow-bin hoisted to a directory outside the workspace root; pnpm/yarn PnP layouts the resolver cannot traverse; flowconfig in a nested package while flow-bin is installed only at the repo root (or vice versa); fresh clone before npm install.","solutions":["Run `npm install --save-dev flow-bin` in one of the directories named in the error message","In workspaces, install flow-bin in the package that owns the .flowconfig, or at the root the extension checks","Alternatively set `flow.pathToFlow` to the absolute binary path"],"exampleFix":"# before: error \"Pkg flow-bin not found in /repo/packages/app, /repo\"\n# flow-bin is not installed anywhere\n\n# after (run in a listed dir, e.g. /repo)\nnpm install --save-dev flow-bin\n# /repo/node_modules/flow-bin now exists and the extension resolves it","handlingStrategy":"validation","validationCode":"function flowBinInstalled(dirs: string[]): boolean {\n  return dirs.some((d) => {\n    try {\n      require.resolve('flow-bin', {paths: [d]});\n      return true;\n    } catch {\n      return false;\n    }\n  });\n}\n// call with [flowconfigDir, workspaceRoot] before enabling useNPMPackagedFlow","typeGuard":null,"tryCatchPattern":"try {\n  const p = await getNpmPackagedFlow(flowconfigDir, workspaceRoot, logger);\n} catch (err) {\n  if (/Pkg flow-bin not found/.test(err.message)) {\n    // fall through to the pathToFlow strategy instead of failing hard\n  } else throw err;\n}","preventionTips":["Install flow-bin in the same package that owns the .flowconfig","Verify node_modules layout after workspace conversions (pnpm/yarn PnP)","Run npm install after clone before opening VS Code"],"tags":["flow-bin","npm","vscode","dependency-missing"],"backgroundTag":"npm-dependency-missing","analyzedSha":"d1341dac899a79c027762f6b423d896045287620","analyzedAt":"2026-08-17T00:07:02.212Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}