For a background on the project, please read this overview.
Flow works with:
- Mac OS X
- Linux (64-bit)
- Windows (64-bit, Windows 10 recommended)
There are binary distributions for each of these platforms and you can also build it from source on any of them as well.
Flow is simple to install: all you need is the
flow binary on your PATH and you're good to go.
Installing Flow Per Project
The recommended way to install Flow is via the
npm package. Adding
flow-bin to your project's
- provides a smoother upgrade experience, since the correct version of Flow is automatically used based on the revision you check out
- installs Flow as part of your existing
- lets you use different versions of Flow on different projects
npm install --save-dev flow-bin node_modules/.bin/flow
Installing Flow Globally
Although not recommended, you can also install Flow globally (for example, perhaps you don't use
The best way to install globally is via
npm install -g flow-bin flow # make sure `npm bin -g` is on your path
On Mac OS X, you can install Flow via the Homebrew package manager:
brew update brew install flow
opam install depext opam depext --install flowtype
If you don't have a new enough version of OCaml to compile Flow, you can also use OPAM to bootstrap a modern version. Install OPAM via the binary packages for your operating system and run:
opam init --comp=4.05.0 opam install flowtype eval `opam config env` flow --help
Getting started with flow is super easy.
- Initialize Flow by running the following command in the root of your project
- Add the following to the top of all the files you want to typecheck
/* @flow */
- Run and see the magic happen
More thorough documentation and many examples can be found at flow.org.
Flow is written in OCaml (OCaml 4.05.0 or higher is required). You can install OCaml on Mac OS X and Linux by following the instructions at ocaml.org.
For example, on Ubuntu 16.04 and similar systems:
sudo apt-get install opam opam init --comp 4.05.0
On OS X, using the brew package manager:
brew install opam opam init --comp 4.05.0
Then, restart your shell and install these additional libraries:
opam update opam pin add flowtype . -n opam install --deps-only flowtype
Once you have these dependencies, building Flow just requires running
This produces a
bin folder containing the
In order to make the flow.js file, you first need to install js_of_ocaml:
opam install -y js_of_ocaml
After that, making flow.js is easy:
flow.js file will also live in the
Building Flow on Windows
This is a little more complicated. Here is a process that works, though it probably can be simplified.
The general idea is that we build in Cygwin, targeting mingw. This gives us a binary that works even outside of Cygwin.
- Install Cygwin 64bit from https://cygwin.com/install.html
- In powershell, run
iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/appveyor-install.ps1"))which will likely run a cygwin setup installer with a bunch of cygwin packages and stuff. This helps make sure that every package that opam needs is available.
- Open the cygwin64 terminal
- Download opam with
curl -fsSL -o opam64.tar.xz https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.1/opam64.tar.xz
tar -xf opam64.tar.xz
- Install opam
- Initialize opam to point to a mingw fork:
opam init -a default "https://github.com/fdopen/opam-repository-mingw.git" --comp "4.05.0+mingw64c" --switch "4.05.0+mingw64c"
- Make sure opam stuff is in your path:
eval `opam config env`
- Clone flow:
git clone https://github.com/facebook/flow.git
- Tell opam to use this directory as the flowtype project:
opam pin add flowtype . -n
- Install system dependencies
opam depext -u flowtype
- Install Flow's dependencies
opam install flowtype --deps-only
- Finally, build Flow:
Running the tests
To run the tests, first compile flow using
make. Then run
bash ./runtests.sh bin/flow
There is a
make test target that compiles and runs tests.
To run a subset of the tests you can pass a second argument to the
bash runtests.sh bin/flow class | grep -v 'SKIP'
Join the Flow community
- Website: https://flow.org
- irc: #flowtype on Freenode
- Twitter: follow @flowtype and #flowtype to keep up with the latest Flow news.
- Stack Overflow: Ask a question with the flowtype tag