Running `flow` inside a brand new project fails

Steps to reproduce:
react-native init someproject && cd someprojectflow initflow- 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
]
}
We are going to provide a flowconfig with sample app soon. cc @sahrens
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.
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
}
]
}
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.
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
Bump. Same issue. Using Flow 0.10.0
uh, wow, I fixed it...?
[libs] should be [library]
Seems like a simple bugfix. Maybe I will dig in to this and fix it?
That results in the flow server not being able start. .flowconfig:23 Unsupported config section: "library"
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!
This looks like the same as #912 #938.
The issue is not upgrading flow. Trying using 0.7.0 , or 0.8.0.
What is the best way to downgrade flow if I have version 0.10.0 installed with homebrew?
brew switch flow 0.8.0
If you don't have this version it will display what versions you have access to.
No joy with 0.9.2, 0.8.0, 0.7.0.
@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?
@jasongonzales23 thanks,it fix my error
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:
- People are having trouble using react-native 0.4.0 with Flow v0.10.0
- People are experiencing other miscellaneous Flow errors
This evening we deployed react-native 0.4.1, which included the following changes:
- Fixed the issues that Flow v0.10.0 noticed.
react-native init yourprojectshould no longer generate a project with Flow errors (according to Flow v0.10.0) - Temporarily disabled the red-box error messages for Flow errors. Users will have to run
flowmanually 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:
- 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)
react-native initgenerates this.flowconfigfile which configures Flow for your new project. I'm going to make the.flowconfigfile specify exactly which version ofFlowyour 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- I'm going to add
flow-binas a npm dependency.flow-binis a pseudo npm package that downloads the correct binary from GitHub based on the version number and your operating system. This way thereact-nativepackager 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!
Thanks @gabelevi! Your plan sounds good to me :+1:
@christopherdro that fixed my error. thanks!
@jasongonzales23 fixed my problem. thx
@jergason Please close this issue since it has been resolved. Thanks @gabelevi!