0
votes

After following this article to set up flow, eslint and prettir exactly(but using yarn instead of npm, if that matters). I either get module not found error on 'react-native' (which would be gone after installing flow-typed) but either way the file in the "Libraries" of react native called "react-native-implementation.js" has errors on almost every line from "cannot fine module 'invariant', 'warnOnce', 'ActivityIndicator'".

Even after installing 'flow-typed' and adding stubs error from App.js goes away but the app does not work throwing this error on Metro server

error: bundling failed: Error: Cannot find module 'babel-preset-react-native' from 'C:\PropertyFinder'
- If you want to resolve "react-native", use "module:react-native"
    at Function.module.exports [as sync] (C:\PropertyFinder\node_modules\resolve\lib\sync.js:58:15)
    at resolveStandardizedName (C:\PropertyFinder\node_modules\@babel\core\lib\config\files\plugins.js:101:31)
    at resolvePreset (C:\PropertyFinder\node_modules\@babel\core\lib\config\files\plugins.js:58:10)
    at loadPreset (C:\PropertyFinder\node_modules\@babel\core\lib\config\files\plugins.js:77:20)
    at createDescriptor (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:154:9)
    at items.map (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:109:29)
    at createPresetDescriptors (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:101:10)

This is not only from my old project but the reproduced one too I need flow for better intellisense.

2

2 Answers

0
votes

I have fixed the error here are the steps I did(there can be improvements):

1.As of now, flow's bin version is 0.97.0 and react-native produces ^0.92.0 so in the .flowconfig I changed it to ^0.97.0 2.Now In the root of you're project create a file flowLibs.js(or anything really). In the .flowconfig under [libs] paste ./flowLibs.js and paste

<PROJECT_ROOT>/node_modules/.*   
<PROJECT_ROOT>/flowLibs.js

under [ignore] tag. 3.Now in the flowLibs.js file you just created above paste

declare module "react-native" { declare module.exports: any; }

or if you have problem with another module then replace react-native with you're module. this also fixes the error cannot resolve module 'react-native'

NOTE: you do not need to install flow-bin

the reason is that flow-type is included with react-native If you have installed flow-language support extension on vs code then latest version of flow-bin client is already present i.e. As of now 0.97.0

-1
votes

standard fix for npm issues

$ rm -rf node_modules
$ npm cache clean -f
$ npm install

You are yarn user, so try delete old node_modules folder and re-run installation.