I created a react native project, and I want to enable flow for my project.
I have flow-bin installed by
npm install --save flow-bin
However, it returns
missing script: flow
when I run
npm run-script flow
Anyone got any idea? Thanks!
You can use npm hook scripts to do something after package is installed. Create node_modules/. hooks/postinstall executable and it will be run also after npm install <package> .
To solve the error "react-scripts is not recognized as an internal or external command, operable program or batch file", open your terminal in your project's root directory and install the react-scripts package by running npm install react-scripts and clear your npm cache if necessary.
npm run sets the NODE environment variable to the node executable with which npm is executed. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install , just in case you've forgotten.
npm run-script flow
will not execute the flow
command, but will just look into the scripts
entry in the package.json
file and execute the command under the flow
entry (see the documentation for more information). This has the advantage that it will include binaries located in your dependencies (a.k.a. binaries inside the node_modules
folder), which is something you usually do not have in your $PATH
, avoiding the need to configure that for every project. Make sure that your package.json
looks something like this:
//...
"scripts":{
//...
"flow": "flow; test $? -eq 0 -o $? -eq 2"
}
//...
Source: docs
Add "flow": "flow" as a new entry under "scripts" in your package.json file:
...
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"flow": "flow"
},
...
The tutorials I was following seem to skip this step but the Facebook github repo has it: https://facebook.github.io/create-react-app/docs/adding-flow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With