Solve Flow error in Visual Studio Code on a Mac OS

Did you ever get the error: "Wrong version of Flow. The config specifies version ^0.182.0 but this is version 0.158.0" in Visual Studio Code. I got it when building React-Native apps. This error causes the Visual Studio Code Flow plugin to crash. I was banging my head to find a solution. I am not really a Linux guy, that is why.

In my situation, the .flowconfig of my project defines version "^0.182.0" where the installed version seems version "0.158.0". It crashes because React Native wants to use a later version than I have installed. Changing the version in the config back to 0.158.0 results in a crash too. Because the configuration uses functionality from a new version of Flow than version 0.158.0.

Flow language support plugin

In Visual Studio Code the Flow Language Support plugin is installed but it does not have anything to do with the version of Flow that is used.

Where is Flow?

Normally Flow will be installed in the path /usr/local/bin/flow or /usr/bin/flow. You can easily find it by calling whereis flow.

Solution

Now you know where Flow resides you can remove it. And re-install it. You do it in the following way:

1sudo rm -rf /usr/local/bin/flow # The dir you found with the whereis command
2yarn global add flow-bin@latest

In my case it results in:

1yarn global v1.22.19
2[1/4] ๐Ÿ”  Resolving packages...
3[2/4] ๐Ÿšš  Fetching packages...
4[3/4] ๐Ÿ”—  Linking dependencies...
5[4/4] ๐Ÿ”จ  Building fresh packages...
6success Installed "flow-bin@0.191.0" with binaries:
7      - flow

Problem solved! Visual Studio Code is running fine, no problems anymore. I hope this helps you out too!

Translations: