Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm run-script flow is not working

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!

like image 986
Leo Chiu Avatar asked Dec 06 '16 15:12

Leo Chiu


People also ask

How do I run a script after npm install?

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> .

How fix react scripts is not recognized as an internal or external command operable program or batch file?

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.

What is npm Run command?

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.


2 Answers

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

like image 146
martinarroyo Avatar answered Nov 15 '22 06:11

martinarroyo


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

like image 40
Chris Owens Avatar answered Nov 15 '22 07:11

Chris Owens