1.在项目的目录下安装flow
yarn add flow-bin -D
2.用flow初始项目,生成对应的.flowconfig文件
yarn flow init
3.启动flow服务
yarn flow start
4.服务启动后,后续即可使用flow命令检查项目文件
yarn flow
注意 在windows下一定要先运行yarn flow start才能直接使用yarn flow,不然会报错:Lost connection to the flow server (0 retries remaining): \Out of retries, exiting!
运行flow之后,有检查失败的文件的的话,控制台就会打印对应的具体错误信息:
注意,flow只会检查加了Flow注释的文件,简称flow文件,即是将// @flow或 /* @flow */加到js文件的最顶部后的那些文件。
5.停止flow服务
yarn flow stop
6.另外,可以不启动flow服务,就可以直接用flow check命令做文件检查。
yarn flow check