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

react-native: Required module not found #3875

Open
kimjuny opened this Issue May 4, 2017 · 12 comments

Comments

Projects
None yet
@kimjuny

kimjuny commented May 4, 2017

.flowconfig

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

index.js

import { View } from 'react-native'; ---> produce: react-native. Required module not found.
...

Maybe my libs settings for flowconfig is broken?

  • react-native 0.42.3
  • flow-bin 0.45.0
@kimjuny

This comment has been minimized.

Show comment
Hide comment
@kimjuny

kimjuny May 4, 2017

Well, I managed to declare a 'react-native' module definition(libdef), this is a workaround, I prefer a general solution(if there is any?).

kimjuny commented May 4, 2017

Well, I managed to declare a 'react-native' module definition(libdef), this is a workaround, I prefer a general solution(if there is any?).

@vTrip

This comment has been minimized.

Show comment
Hide comment
@vTrip

vTrip Jun 5, 2017

Could you share you solution, I am getting this for all my modules that i import into files.

vTrip commented Jun 5, 2017

Could you share you solution, I am getting this for all my modules that i import into files.

@jukben

This comment has been minimized.

Show comment
Hide comment
@jukben

jukben Jun 5, 2017

@vTrip For example:

Extend flowconfig like this

.flowconfig
module.name_mapper='\(react-native\)' -> '<PROJECT_ROOT>/modulesStub.js'

and then create stub like this:

modulesStub.js
export default {};

jukben commented Jun 5, 2017

@vTrip For example:

Extend flowconfig like this

.flowconfig
module.name_mapper='\(react-native\)' -> '<PROJECT_ROOT>/modulesStub.js'

and then create stub like this:

modulesStub.js
export default {};

@imerkle

This comment has been minimized.

Show comment
Hide comment
@imerkle

imerkle Jun 21, 2017

This should work

[ignore]
<PROJECT_ROOT>/node_modules/[^r].* 

to generate custom regex goto https://dsslimshaddy.github.io/flowignore/

imerkle commented Jun 21, 2017

This should work

[ignore]
<PROJECT_ROOT>/node_modules/[^r].* 

to generate custom regex goto https://dsslimshaddy.github.io/flowignore/

@spinningarrow

This comment has been minimized.

Show comment
Hide comment
@spinningarrow

spinningarrow Aug 31, 2017

Seeing this issue with flow 0.53.1 as well. Any idea what's causing it?

spinningarrow commented Aug 31, 2017

Seeing this issue with flow 0.53.1 as well. Any idea what's causing it?

@asolove asolove added the react-native label Sep 1, 2017

@dozoisch

This comment has been minimized.

Show comment
Hide comment
@dozoisch

dozoisch Sep 29, 2017

Getting the same with flow 0.53.1 and react-native August.

I have unsafe.enable_getters_and_setters=true. Is there any thing in terms of extension or anything that I need?

dozoisch commented Sep 29, 2017

Getting the same with flow 0.53.1 and react-native August.

I have unsafe.enable_getters_and_setters=true. Is there any thing in terms of extension or anything that I need?

@divyanshu013

This comment has been minimized.

Show comment
Hide comment
@divyanshu013

divyanshu013 Oct 26, 2017

Here's a quick solution that works for me to ignore the flow related errors for react-native

  1. Change into your project directory
cd my-awesome-project
  1. Create a directory called flow-typed in your project if it doesn't exists
mkdir flow-typed
  1. Add a file react-native.js
touch react-native.js
  1. Add the following to react-native.js and hit save using your favorite editor
declare module 'react-native' {
	declare module.exports: any;
}

divyanshu013 commented Oct 26, 2017

Here's a quick solution that works for me to ignore the flow related errors for react-native

  1. Change into your project directory
cd my-awesome-project
  1. Create a directory called flow-typed in your project if it doesn't exists
mkdir flow-typed
  1. Add a file react-native.js
touch react-native.js
  1. Add the following to react-native.js and hit save using your favorite editor
declare module 'react-native' {
	declare module.exports: any;
}
@bodolsog

This comment has been minimized.

Show comment
Hide comment
@bodolsog

bodolsog Jan 27, 2018

@divyanshu013 You forgot mention that there is needed also:

  1. Add /flow-typed/ into .flowconfig as included libs:
;.flowconfig file

[include]

[libs]
; Your other libs, usually followed:
; node_modules/react-native/Libraries/react-native/react-native-interface.js
; node_modules/react-native/flow/
; node_modules/expo/flow/
flow-typed/

After that flow will known, that should check flow-typed declarations for all "missed" libs

bodolsog commented Jan 27, 2018

@divyanshu013 You forgot mention that there is needed also:

  1. Add /flow-typed/ into .flowconfig as included libs:
;.flowconfig file

[include]

[libs]
; Your other libs, usually followed:
; node_modules/react-native/Libraries/react-native/react-native-interface.js
; node_modules/react-native/flow/
; node_modules/expo/flow/
flow-typed/

After that flow will known, that should check flow-typed declarations for all "missed" libs

@divyanshu013

This comment has been minimized.

Show comment
Hide comment
@divyanshu013

divyanshu013 Jan 27, 2018

Actually the above solution worked for me at the point of writing. I haven't used flow since then so a lot might have changed. Thanks for updating

divyanshu013 commented Jan 27, 2018

Actually the above solution worked for me at the point of writing. I haven't used flow since then so a lot might have changed. Thanks for updating

@zhiquan-yu

This comment has been minimized.

Show comment
Hide comment
@zhiquan-yu

zhiquan-yu Feb 1, 2018

@divyanshu013 I think it's a good solution, maybe react-native team can give us a library defination in https://github.com/flowtype/flow-typed

zhiquan-yu commented Feb 1, 2018

@divyanshu013 I think it's a good solution, maybe react-native team can give us a library defination in https://github.com/flowtype/flow-typed

@3DEsprit

This comment has been minimized.

Show comment
Hide comment
@3DEsprit

3DEsprit Mar 24, 2018

Probably quite obvious by now, but still an issue with v0.63.0 using React-Native 0.53.0's .flowconfig.

3DEsprit commented Mar 24, 2018

Probably quite obvious by now, but still an issue with v0.63.0 using React-Native 0.53.0's .flowconfig.

@saadq

This comment has been minimized.

Show comment
Hide comment
@saadq

saadq Mar 24, 2018

It looks like someone wrote up a Flow libdef for react-native as a GitHub gist. It looks like this would be a good place to start for submitting it to flow-typed.

Note – Based on the comments in that gist, there do seem to be some minor errors with that libdef that need to be fixed though.

saadq commented Mar 24, 2018

It looks like someone wrote up a Flow libdef for react-native as a GitHub gist. It looks like this would be a good place to start for submitting it to flow-typed.

Note – Based on the comments in that gist, there do seem to be some minor errors with that libdef that need to be fixed though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment