Flow-bin: Flow Type Checker Binary Wrapper

0.310.0 · maintenance · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

const execFile = require('child_process').execFile;
const flow = require('flow-bin');

console.log(`Running Flow from: ${flow}`);

execFile(flow, ['check', '--json'], (err, stdout, stderr) => {
  if (err) {
    console.error('Flow check failed:', err.message);
    if (stderr) console.error('Stderr:', stderr);
    try {
      const errorOutput = JSON.parse(stdout);
      console.error('Flow errors:', JSON.stringify(errorOutput, null, 2));
    } catch (parseErr) {
      console.error('Stdout (non-JSON on error):', stdout);
    }
    process.exit(1);
  } else {
    console.log('Flow check successful.');
    try {
      const result = JSON.parse(stdout);
      if (result.errors && result.errors.length > 0) {
        console.warn('Flow reported warnings/errors:', JSON.stringify(result.errors, null, 2));
      } else {
        console.log('No Flow issues found.');
      }
    } catch (parseErr) {
      console.warn('Could not parse Flow output as JSON:', stdout);
    }
  }
});

view raw JSON →