Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running flow inside a brand new project fails #784

Closed
jergason opened this issue Apr 9, 2015 · 41 comments
Closed

Running flow inside a brand new project fails #784

jergason opened this issue Apr 9, 2015 · 41 comments
Labels
JavaScript Resolution: Locked This issue was locked by the bot.

Comments

@jergason
Copy link

jergason commented Apr 9, 2015

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
  ]
}
@frantic
Copy link
Contributor

frantic commented Apr 10, 2015

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

@bhosmer
Copy link
Contributor

bhosmer commented Apr 10, 2015

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.

@sthomp
Copy link

sthomp commented Apr 18, 2015

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
      }
   ]
}

@jergason
Copy link
Author

The default .flowconfig file isn't correct. See #784 (comment) for an explanation of how to get it running.

@sthomp
Copy link

sthomp commented Apr 19, 2015

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

@jasongonzales23
Copy link

Bump. Same issue. Using Flow 0.10.0

@jasongonzales23
Copy link

uh, wow, I fixed it...?

[libs] should be [library]

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

@christopherdro
Copy link
Contributor

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

@jasongonzales23
Copy link

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!

@christopherdro
Copy link
Contributor

This looks like the same as #912 #938.

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

@pavelnikolov
Copy link

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

@christopherdro
Copy link
Contributor

brew switch flow 0.8.0

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

@jasongonzales23
Copy link

No joy with 0.9.2, 0.8.0, 0.7.0.

@christopherdro
Copy link
Contributor

@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?

@princeli
Copy link

@jasongonzales23 thanks,it fix my error

@gabelevi
Copy link
Contributor

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!

@brentvatne
Copy link
Collaborator

Thanks @gabelevi! Your plan sounds good to me 👍

@watsonwu9
Copy link

@christopherdro that fixed my error. thanks!

@watsonwu9
Copy link

@jasongonzales23 fixed my problem. thx

@christopherdro
Copy link
Contributor

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

@atticoos
Copy link
Contributor

This appears to have become an issue again on 0.17.0 of RN.

The .flowconfig requires flow at 0.19.0, which I have installed, yet it fails to resolve any react native modules:

screen shot 2015-12-23 at 11 36 25 am

This can be reproduced on a fresh project.

@satya164 satya164 reopened this Dec 23, 2015
@klvnptr
Copy link

klvnptr commented Dec 31, 2015

+1

@brenmcnamara
Copy link

+1

@atticoos
Copy link
Contributor

atticoos commented Jan 3, 2016

I feel like I have nowhere to start with using Flow right now. Has anyone got an RN project running with Flow?

@brentvatne
Copy link
Collaborator

cc @vjeux ^

@vjeux
Copy link
Contributor

vjeux commented Jan 3, 2016

@gabelevi is the right person to talk to about flow :)

@satya164
Copy link
Contributor

satya164 commented Jan 3, 2016

@gabelevi Lemme know if you need help with testing this. I've a project already setup with flow.

@artyomtrityak
Copy link
Contributor

+1, it looks like flow just does not work with RN from the box right now, any suggestions how to fix this?
All errors i see are related to require('NativeModules')

@artyomtrityak
Copy link
Contributor

There is one solution i can propose to fix this issue - it is possible to create interface file for react-native and ExecutionEnvironment.

interfaces/react-native.js

declare module "react-native" {
  declare var exports: (callback: any) => any;
}

declare module ExecutionEnvironment {
  declare var exports: (callback: any) => any; 
}

and add to .flowconfig

[libs]
interfaces/
....
[ignore]
.*/node_modules/react-native/.*
....

[version]
0.20.1

This works for me right now, i can create pull request to update yeoman generator

@Emilios1995
Copy link
Contributor

👍
I would love complete support out of the box. Right now I get the following out of a new project
screen shot 2016-02-28 at 12 31 07 am

@atticoos
Copy link
Contributor

This seems to be working for 0.21.0-rc on a fresh project. What version of RN is that @Emilios1995?

@cupofjoakim
Copy link

cupofjoakim commented Jul 13, 2016

Also on a pretty new project over here, getting 19 errors from running 'flow'.
RN @ 0.29.0
flow-bin @ 0.28.0

Here's the output

@phil-travelbytes
Copy link

+1 (agree with cupofjoakim, have issue with default project seed)

@luiswdy
Copy link

luiswdy commented Jul 20, 2016

+1. I got as same issue as the one cupofjoakim reported.

@phil-travelbytes
Copy link

The 'init' project creates a .flowconfig which specifies [version] 0.27.0 - which works according to Michael Helvey in this stackoverflow post.

The actual issue for me is that flow binaries are not available in brew for back sourcing. I have flow version 0.23.1 and now 0.28, and 0.29.

brew upgrade flow --version 0.27.0
Error: No available formula with the name "0.27.0"

If these were available it would be simple to regress flow to the correct version, and then happy days :)

@satya164
Copy link
Contributor

@phil-travelbytes

npm install flow-bin@0.27.0

@phil-travelbytes
Copy link

@satya164 thank you!
Works a treat running via <PROJECT_ROOT>/node_modules/.bin/flow ...

but how do I include it in Nuclide?

@satya164
Copy link
Contributor

Nuclide doesn't support it yet. But support is coming - https://twitter.com/natmote/status/755871913864466433

@justin808
Copy link

Any recommendations if flow should be a dev dependency of a react-native project? I'm guessing yes, since the eslint version very sensitive.

@mt81
Copy link

mt81 commented Aug 3, 2016

+1

@hramos
Copy link
Contributor

hramos commented Nov 1, 2016

Looks like this can be closed as well (see #8773).

@hramos hramos closed this as completed Nov 1, 2016
@facebook facebook locked as resolved and limited conversation to collaborators Jul 23, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
JavaScript Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.