Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Flow: Cannot resolve module react-native

I have started a React Native project from scratch and configured Flow.

When I run npm run flow everything works fine except a small problem with the react-native module:

Cannot resolve module react-native.

I am using:

"react": "16.3.1",
"react-native": "0.55.3",
"flow-bin": "0.74.0"

My .flowconfig is:

[ignore]
.*/node_modules/.*
.*/.cache/.*
.*/test/.*

[include]

[libs]

[lints]

[options]

[strict]

Tried with "flow-typed": "2.4.0" but didn't work.

I found the following issue but there aren't any solutions :/

like image 504
Hristo Eftimov Avatar asked Aug 23 '26 01:08

Hristo Eftimov


1 Answers

You need to add a type definition for react-native.

Create a folder called type-def-lib in your project root and inside create a file called react-native.js with these contents

declare module 'react-native' {
  declare module.exports: any
}

Then in your .flowconfig add that folder under libs:

[libs]
./type-def-libs

Now yarn run flow should produce no errors.

like image 67
Robbie Milejczak Avatar answered Aug 25 '26 22:08

Robbie Milejczak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!