Search code examples
javascripttypesflowtypetypechecking

Setting Up Flow in An Existing Project


Am running Ubuntu 16.04. I am setting up Flow as per the instructions in the link, however, on the next page (usage), where we are directed to run the command:

flow init

I get the error:

No command found...

Which makes sense as flow was not installed globally, but as a dev-dependency within the existing project directory. They also recommend & I quote:

Flow works best when installed per-project with explicit versioning rather than globally.

So, my question is, am I missing a step in the installation of flow, which is causing the error? Or should I go ahead & yarn add flow globally.

Flow Installation Instructions: https://flow.org/en/docs/install/


Solution

  • Yarn will only install globally if you run # yarn global <add/bin/ls/remove/upgrade> [--prefix]. Using $ yarn add --dev flow-bin as the documentation states will be sufficient. Then, you should run $ yarn run flow.

    The full instructions are here, and you can follow it with no problems.

    You can also install it using npm instead of yarn:

    $ npm install --save flow-bin

    Edit

    To get the flow init command to work you have to install Flow CLI globally, as the local flow binary won't be in your $PATH environment variable. The command is almost the same:

    # npm install --global flow-bin

    Alternatively you can execute the binary from within your local path. Something like: $ ./node_modules/.bin/flow init