react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Running `flow` inside a brand new project fails

Open jergason opened this issue 11 years ago • 41 comments

flowsad

Steps to reproduce:

  1. react-native init someproject && cd someproject
  2. flow init
  3. flow
  4. Cry because there are 438 errors.

I am on OS X 10.10.2, iojs 1.6.3, react-native 0.3.10, and flow 0.8.

Here is the JSON from the first few errors:

{
  "passed": false,
  "errors": [
    {
      "message": [
        {
          "descr": "NativeModules\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js",
          "line": 14,
          "endline": 14,
          "start": 29,
          "end": 52
        }
      ]
    },
    {
      "message": [
        {
          "descr": "invariant\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js",
          "line": 16,
          "endline": 16,
          "start": 17,
          "end": 36
        }
      ]
    },
    {
      "message": [
        {
          "descr": "NativeModules\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/AdSupport/AdSupportIOS.js",
          "line": 14,
          "endline": 14,
          "start": 17,
          "end": 40
        }
      ]
    },
    {
      "message": [
        {
          "descr": "NativeModules\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/AnimationExperimental.js",
          "line": 14,
          "endline": 14,
          "start": 27,
          "end": 50
        }
      ]
    },
    {
      "message": [
        {
          "descr": "AnimationUtils\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/AnimationExperimental.js",
          "line": 15,
          "endline": 15,
          "start": 22,
          "end": 46
        }
      ]
    },
    {
      "message": [
        {
          "descr": "identifier __DEV__\nUnknown global name",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/AnimationExperimental.js",
          "line": 75,
          "endline": 75,
          "start": 5,
          "end": 11
        }
      ]
    },
    {
      "message": [
        {
          "descr": "ReactPropTypes\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/LayoutAnimation.js",
          "line": 14,
          "endline": 14,
          "start": 17,
          "end": 41
        }
      ]
    },
// etc
  ]
}

jergason avatar Apr 09 '15 22:04 jergason

We are going to provide a flowconfig with sample app soon. cc @sahrens

frantic avatar Apr 10 '15 00:04 frantic

HI @jergason - so the problem is that flow init writes an empty .flowconfig into the root of the new project directory. (react-native init should instead write one that's set up properly, but per @frantic, that's not happening just yet.)

For now, the workaround is to copy the .flowconfig from the root of react-native into your project directory and tweak it, by replacing the two lines in the [library] section with this one:

node_modules/react-native/Libraries/react-native/react-native-interface.js

That should get you to 0 errors using Flow 0.8.0.

bhosmer avatar Apr 10 '15 00:04 bhosmer

Im still having issues getting flow to run without errors. After I react-native init hello I can see there is a .flowconfig provided. But when I run flow I see errors. Currently using flow 0.9.2.

{  
   "status":500,
   "message":"Flow found type errors.  If you think these are wrong, make sure your flow bin and .flowconfig are up to date, or disable with --skipflow.",
   "type":"FlowError",
   "errors":[  
      {  
         "description":"E1: function call\nCallable signature not found in",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/AppRegistry/AppRegistry.js",
         "lineNumber":57,
         "column":9
      },
      {  
         "description":"  E1: exports",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/ReactIOS/renderApplication.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E2: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E3: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E4: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/MapView/MapView.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E5: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E6: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E7: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/SliderIOS/SliderIOS.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E8: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/StaticRenderer.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E9: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E10: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E11: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E12: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/TextInput/TextInput.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E13: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/Touchable/TouchableBounce.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E14: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E15: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/View/View.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E16: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E17: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Image/Image.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E18: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/ReactIOS/renderApplication.ios.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E19: property propTypes\nProperty not found in",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js",
         "lineNumber":28,
         "column":10
      },
      {  
         "description":"  E19: exports",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Components/View/View.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E20: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/Text/Text.js",
         "lineNumber":0,
         "column":0
      },
      {  
         "description":"E21: \nFailure(\"internal error: package /Users/thompsons/node_modules/React/package.json not found\")",
         "filename":"/Users/thompsons/Code/reactjs/hello/node_modules/react-native/Libraries/react-native/react-native.js",
         "lineNumber":0,
         "column":0
      }
   ]
}

sthomp avatar Apr 18 '15 22:04 sthomp

The default .flowconfig file isn't correct. See https://github.com/facebook/react-native/issues/784#issuecomment-94208658 for an explanation of how to get it running.

jergason avatar Apr 18 '15 23:04 jergason

Here is the .flowconfig that react-native generated which matches the comments above:

[ignore]

# We fork some components by platform.
.*/*.web.js
.*/*.android.js

# Some modules have their own node_modules with overlap
.*/node_modules/node-haste/.*

# Ignore react-tools where there are overlaps, but don't ignore anything that
# react-native relies on
.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js
.*/node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js
.*/node_modules/react-tools/src/browser/ui/React.js
.*/node_modules/react-tools/src/core/ReactInstanceHandles.js
.*/node_modules/react-tools/src/event/EventPropagators.js

# Ignore jest
.*/react-native/node_modules/jest-cli/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js

[options]
module.system=haste

sthomp avatar Apr 19 '15 17:04 sthomp

Bump. Same issue. Using Flow 0.10.0

jasongonzales23 avatar Apr 25 '15 16:04 jasongonzales23

uh, wow, I fixed it...?

[libs] should be [library]

Seems like a simple bugfix. Maybe I will dig in to this and fix it?

jasongonzales23 avatar Apr 25 '15 16:04 jasongonzales23

That results in the flow server not being able start. .flowconfig:23 Unsupported config section: "library"

christopherdro avatar Apr 25 '15 19:04 christopherdro

Heh, yeah I noticed that too late. All I noticed was that the demo then worked, which I assume is because flow didn't run at all. So, I still don't know how to get flow working in this demo.

But for fun you could try the following instead of [libs]

[kittens] [pygmygoats] [ufos]

and they all have the same result!

jasongonzales23 avatar Apr 25 '15 19:04 jasongonzales23

This looks like the same as #912 #938.

The issue is not upgrading flow. Trying using 0.7.0 , or 0.8.0.

christopherdro avatar Apr 25 '15 19:04 christopherdro

What is the best way to downgrade flow if I have version 0.10.0 installed with homebrew?

pavelnikolov avatar Apr 26 '15 15:04 pavelnikolov

brew switch flow 0.8.0

If you don't have this version it will display what versions you have access to.

christopherdro avatar Apr 26 '15 17:04 christopherdro

No joy with 0.9.2, 0.8.0, 0.7.0.

jasongonzales23 avatar Apr 26 '15 17:04 jasongonzales23

@jasongonzales23 After downgrading flow make sure to cd into your proj directory then try restarting the flow server by using 'flow stop' and 'flow start'.

See if that helps.

@jergason Did you resolve this issue?

christopherdro avatar Apr 27 '15 15:04 christopherdro

@jasongonzales23 thanks,it fix my error

princeli avatar Apr 28 '15 00:04 princeli

Hi everyone, thanks for the reports and sorry that you guys are having trouble! I'm a member of the Flow team and we spent the last day looking into this issue. There are two problems being discussed in this issue, both regarding react-native and Flow having trouble working together. The two problems are:

  1. People are having trouble using react-native 0.4.0 with Flow v0.10.0
  2. People are experiencing other miscellaneous Flow errors

This evening we deployed react-native 0.4.1, which included the following changes:

  1. Fixed the issues that Flow v0.10.0 noticed. react-native init yourproject should no longer generate a project with Flow errors (according to Flow v0.10.0)
  2. Temporarily disabled the red-box error messages for Flow errors. Users will have to run flow manually to see Flow errors. We on the Flow team think react-native is pretty awesome and don't want to block anyone from trying it out while we figure out how to properly pin Flow versions to React.

Over the next week I'm going to try and tackle this problem of making sure that people use the right version of Flow with each version of react-native. Here are my tentative plans:

  1. Introduce an option to turn the flow checks on/off when you run your react-native app (and thus whether to show the red box)
  2. react-native init generates this .flowconfig file which configures Flow for your new project. I'm going to make the .flowconfig file specify exactly which version of Flow your project expects. That way if you're running the wrong version of Flow you'll know immediately, rather than having to guess from some strange error message
  3. I'm going to add flow-bin as a npm dependency. flow-bin is a pseudo npm package that downloads the correct binary from GitHub based on the version number and your operating system. This way the react-native packager can always use the correct version of Flow when doing it's Flow checking.

So yeah, sorry for the pain, thanks for the report, and look for some related improvements shortly!

gabelevi avatar Apr 28 '15 03:04 gabelevi

Thanks @gabelevi! Your plan sounds good to me :+1:

brentvatne avatar Apr 28 '15 05:04 brentvatne

@christopherdro that fixed my error. thanks!

xkangai avatar Apr 30 '15 09:04 xkangai

@jasongonzales23 fixed my problem. thx

xkangai avatar Apr 30 '15 11:04 xkangai

@jergason Please close this issue since it has been resolved. Thanks @gabelevi!

christopherdro avatar Apr 30 '15 17:04 christopherdro