{"id":15619,"library":"flow-bin","title":"Flow-bin: Flow Type Checker Binary Wrapper","description":"Flow-bin is a wrapper package that provides the Flow static type checker binary for JavaScript projects. Developed primarily by Facebook/Meta, Flow offers static analysis capabilities similar to TypeScript, inferring types and catching errors before runtime. The package, currently at version `0.310.0`, bundles the corresponding Flow `0.310.0` binary, making it accessible via `npm` or `yarn` scripts and programmatically through Node.js's `child_process` module. While Flow itself is still actively developed and utilized internally at Meta, its public GitHub repository has been archived, meaning external contributions are no longer accepted, and community support is more limited. This positions `flow-bin` primarily as a maintenance package for delivering Meta's internal Flow updates to the public, rather than an actively evolving open-source project. Its release cadence is tied directly to Flow's internal release schedule. It serves as an alternative to TypeScript for adding static typing to JavaScript projects.","status":"maintenance","version":"0.310.0","language":"javascript","source_language":"en","source_url":"https://github.com/flowtype/flow-bin","tags":["javascript","cli-app","cli","bin","binary","flow","facebook","type","inference"],"install":[{"cmd":"npm install flow-bin","lang":"bash","label":"npm"},{"cmd":"yarn add flow-bin","lang":"bash","label":"yarn"},{"cmd":"pnpm add flow-bin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a string representing the absolute path to the Flow binary. CommonJS `require()` is the most common and reliable method. While modern Node.js environments or bundlers might allow `import flowBinaryPath from 'flow-bin'` for ESM contexts, `flow-bin` is primarily a CJS package.","wrong":"import { flowBinaryPath } from 'flow-bin'; // Not a named export.\nimport flowBinaryPath from 'flow-bin'; // May fail in CJS projects without configuration.","symbol":"flowBinaryPath","correct":"const flowBinaryPath = require('flow-bin');"}],"quickstart":{"code":"const execFile = require('child_process').execFile;\nconst flow = require('flow-bin');\n\nconsole.log(`Running Flow from: ${flow}`);\n\nexecFile(flow, ['check', '--json'], (err, stdout, stderr) => {\n  if (err) {\n    console.error('Flow check failed:', err.message);\n    if (stderr) console.error('Stderr:', stderr);\n    try {\n      const errorOutput = JSON.parse(stdout);\n      console.error('Flow errors:', JSON.stringify(errorOutput, null, 2));\n    } catch (parseErr) {\n      console.error('Stdout (non-JSON on error):', stdout);\n    }\n    process.exit(1);\n  } else {\n    console.log('Flow check successful.');\n    try {\n      const result = JSON.parse(stdout);\n      if (result.errors && result.errors.length > 0) {\n        console.warn('Flow reported warnings/errors:', JSON.stringify(result.errors, null, 2));\n      } else {\n        console.log('No Flow issues found.');\n      }\n    } catch (parseErr) {\n      console.warn('Could not parse Flow output as JSON:', stdout);\n    }\n  }\n});\n","lang":"javascript","description":"This quickstart demonstrates how to programmatically invoke the Flow binary using Node.js's `child_process.execFile` and parse its JSON output for type checking results."},"warnings":[{"fix":"Be aware that community support and external development for Flow are limited. For open-source projects, consider alternatives like TypeScript for more active community engagement and ecosystem tools.","message":"The Flow type checker project, which `flow-bin` wraps, has archived its public GitHub repository and no longer accepts external contributions. While still developed internally by Meta, this significantly limits community-driven feature development and direct public bug reporting for the upstream tool.","severity":"breaking","affected_versions":">=0.105.0"},{"fix":"Always review Flow's official release notes when upgrading `flow-bin` to understand potential breaking changes or new configuration requirements for the type checker itself.","message":"The `flow-bin` package version is directly coupled to the Flow type checker version it bundles. Breaking changes or new features in Flow itself will directly impact users of `flow-bin`, even if `flow-bin`'s wrapper logic hasn't changed.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure you are using `flow-bin@v0.105.1` or newer if targeting Flow `v0.105.0` to guarantee the binaries are included.","message":"The `flow-bin@v0.105.0` npm release was published without the actual Flow binaries, leading to 'command not found' errors. This required a patch release `v0.105.1`.","severity":"gotcha","affected_versions":"0.105.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Try running `npm rebuild flow-bin` or `npm install --force` to ensure the package and its binaries are correctly installed. Verify the version you are using is not `0.105.0`.","cause":"The Flow binary was not found at the expected path, often due to an incomplete `flow-bin` installation or a corrupted package.","error":"Error: Command failed: /path/to/node_modules/flow-bin/flow check\n/bin/sh: /path/to/node_modules/flow-bin/flow: No such file or directory"},{"fix":"Create a `.flowconfig` file in your project's root directory. A minimal `.flowconfig` can be empty or include `[options]` and `[ignore]` sections. Refer to Flow documentation for configuration details.","cause":"Flow requires a `.flowconfig` file in the project root to operate. This error indicates it's missing or inaccessible.","error":"Error: Linter: Failed to load Flow config at path. Please make sure that a .flowconfig file is present in your project root or specified using --flowconfig."},{"fix":"For CommonJS environments, use `const flowPath = require('flow-bin');`. If you intend to use ESM, ensure your `package.json` contains `\"type\": \"module\"` and your Node.js version supports ESM, or use a bundler like Webpack or Rollup configured for ESM.","cause":"Attempting to use ESM `import flowPath from 'flow-bin'` in a Node.js environment configured for CommonJS, or without proper transpilation.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm"}