facebook/flow · error · Error

Pkg flow-bin not found in ${dirsToCheck.join(', ')}

Error message

Pkg flow-bin not found in ${dirsToCheck.join(', ')}

What it means

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.

Source

Thrown at packages/flow-for-vscode/src/utils/getFlowPath.ts:97

  workspaceRoot: string,
  logger: Logger,
): Promise<string> {
  const dirsToCheck = [
    // a) check in flowconfig dir
    flowconfigDir,
    // b) check in workspaceRoot (ignore if flowconfigDir and workspaceRoot same)
    flowconfigDir !== workspaceRoot ? workspaceRoot : null,
  ].filter((v) => v != null);

  for (let i = 0; i < dirsToCheck.length; i += 1) {
    // eslint-disable-next-line no-await-in-loop
    const flowPath = await getFlowBinPath(dirsToCheck[i], logger);
    if (flowPath) {
      return flowPath;
    }
  }

  throw new Error(`Pkg flow-bin not found in ${dirsToCheck.join(', ')}`);
}

async function getCommandFlowPath(
  command: string,
  logger: Logger,
): Promise<string> {
  logger.trace(`Checking '${command}'`);
  const flowPath = await which(command);
  if (!flowPath) {
    throw new Error(`'${command}' not found`);
  }
  return flowPath;
}

function getBundledFlowPath(): string {
  const extensionPath = getExtensionPath();
  // NOTE: 'vsce package' never bundles node_modules/.bin folder
  // (see: https://github.com/Microsoft/vscode/issues/53916)

View on GitHub (pinned to d1341dac89)

Solutions

  1. Run `npm install --save-dev flow-bin` in one of the directories named in the error message
  2. In workspaces, install flow-bin in the package that owns the .flowconfig, or at the root the extension checks
  3. Alternatively set `flow.pathToFlow` to the absolute binary path

Example fix

# before: error "Pkg flow-bin not found in /repo/packages/app, /repo"
# flow-bin is not installed anywhere

# after (run in a listed dir, e.g. /repo)
npm install --save-dev flow-bin
# /repo/node_modules/flow-bin now exists and the extension resolves it
Defensive patterns

Strategy: validation

Validate before calling

function flowBinInstalled(dirs: string[]): boolean {
  return dirs.some((d) => {
    try {
      require.resolve('flow-bin', {paths: [d]});
      return true;
    } catch {
      return false;
    }
  });
}
// call with [flowconfigDir, workspaceRoot] before enabling useNPMPackagedFlow

Try / catch

try {
  const p = await getNpmPackagedFlow(flowconfigDir, workspaceRoot, logger);
} catch (err) {
  if (/Pkg flow-bin not found/.test(err.message)) {
    // fall through to the pathToFlow strategy instead of failing hard
  } else throw err;
}

Prevention

When it happens

Trigger: `flow.useNPMPackagedFlow` is enabled and neither <flowconfigDir> nor <workspaceRoot> contains node_modules/flow-bin with a resolvable binary.

Common situations: 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.

Related errors


AI-assisted analysis of facebook/flow@d1341dac89 (2026-08-17). Data as JSON: /api/errors/fe3331a21856f20d. Report an issue: GitHub.