← Back to facebook/flow

How to Deploy & Use facebook/flow

Flow Deployment and Usage Guide

Prerequisites

System Requirements

  • Operating Systems: macOS (x86_64), Linux (x86_64 and arm64), Windows (x86_64, Windows 10 recommended)
  • OCaml: Version 5.2.0 (required for building from source)

Development Dependencies

  • macOS: brew install opam
  • Debian/Ubuntu: sudo apt-get install opam
  • Other Linux: See opam installation docs
  • Windows: Cygwin with dependencies including make, gcc, and g++

Optional Dependencies

  • JavaScript Parser: For using Flow's parser from JavaScript, install the flow-parser npm package

Installation

Binary Installation

  1. Download the appropriate binary distribution from the Flow releases page
  2. Extract and add the binary to your system PATH

Building from Source

  1. Initialize opam:

    # On Mac and Linux:
    opam init
    
    # On Windows:
    scripts/windows/init_opam.sh
    
  2. Validate opam version (must be 2.x.x):

    opam --version
    
  3. Install Flow's OCaml dependencies:

    # From within the git checkout
    make deps
    
  4. Build the flow binary:

    eval $(opam env)
    make
    

    This produces the bin/flow binary.

  5. Build flow.js (optional):

    opam install -y js_of_ocaml.5.7.2
    make js
    

    This produces bin/flow.js.

Configuration

Environment Setup

  • Ensure opam is properly initialized and in your PATH
  • Set up OCaml environment variables:
    eval $(opam env)
    

Project Configuration

  • Create a .flowconfig file in your project root to configure Flow settings
  • Configure Flow settings in your IDE (see VS Code extension section below)

Build & Run

Development

  1. Start Flow server:

    flow start
    
  2. Check files:

    flow check
    
  3. Stop Flow server:

    flow stop
    

Production

  • Use the pre-built binary for production deployments
  • Configure Flow to run as a background service or daemon process

Deployment

Platform Recommendations

  • Node.js Projects: Install Flow as a dev dependency via npm
  • CI/CD: Include Flow in your build pipeline (GitHub Actions, CircleCI, etc.)
  • Docker: Create a Docker image with Flow pre-installed for consistent environments

VS Code Extension Deployment

For VS Code users, install the official Flow extension:

  1. Install the extension from the VS Code Marketplace
  2. Configure the extension settings:
    • useNPMPackagedFlow: Use npm-packaged Flow binary
    • pathToFlow: Custom path to Flow binary
    • useBundledFlow: Use bundled Flow version
    • stopFlowOnExit: Stop Flow server when VS Code exits
    • logLevel: Set logging verbosity

Troubleshooting

Common Issues and Solutions

1. OCaml Dependency Issues

Problem: Error finding ocaml-base-compiler version Solution: Update opam repository and dependencies:

opam update
opam upgrade

2. Platform-Specific Binary Issues

Problem: Cannot find correct binary for platform Solution: Verify platform and architecture:

echo $OSTYPE
uname -m

3. Flow Server Connection Issues

Problem: Flow server fails to start or connect Solution: Check Flow configuration and ensure proper permissions:

flow status
flow check

4. VS Code Extension Issues

Problem: Diagnostics not showing in VS Code Solution: Verify extension configuration:

  • Check FlowLanguageClientConfig settings
  • Ensure proper document selector matches
  • Verify Flow server is running

5. Parser Issues

Problem: Issues with JavaScript parser integration Solution: Use the flow-parser npm package for JavaScript integration:

npm install flow-parser

Getting Help