Skip to content

"Required module not found" with Flow #137

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

Closed
msolli opened this issue Oct 6, 2015 · 9 comments
Closed

"Required module not found" with Flow #137

msolli opened this issue Oct 6, 2015 · 9 comments

Comments

@msolli
Copy link

msolli commented Oct 6, 2015

I'm experimenting with Flow, but I'm getting errors when importing react-redux:

/Users/<...>/foo.js:4:33,45: react-redux
Required module not found

I've made the error go away by adding this to .flowconfig:

[options]
module.name_mapper='\(react-redux\)' -> '\1/lib/index'

This might by caused by facebook/flow#654. Maybe the error will go away when that issue is fixed. In the meantime, is there anything that could be done in react-redux to avoid the above work-around?

@gaearon
Copy link
Contributor

gaearon commented Oct 6, 2015

I don't really know enough about Flow to fix this.
@leoasis, any ideas?

@leoasis
Copy link

leoasis commented Oct 6, 2015

Mmm since react-redux isn't even typed, perhaps a better option would be to just add it in the ignore paths?

If you feel adventurous you can even grab the declaration modules in here and try them so you can have the react-redux usage type checked (and redux and redux-thunk if you're using it). You'd need to put those files in a folder and specify them in the [libs] option in .flowconfig.

@msolli
Copy link
Author

msolli commented Oct 9, 2015

Thanks guys. I had stupidly ignored every package.json in my project in .flowconfig, which caused all sorts of strange problems. Sorry for the noise. I'll check out those declaration files.

@msolli msolli closed this as completed Oct 9, 2015
@averyvery
Copy link

averyvery commented Oct 6, 2016

Ran into this issue myself with the flow config of

.*/node_modules/.*

[options]
module.system.node.resolve_dirname=apps

Other modules seem to import correctly, but for some reason flow throws "not found" for react-redux in particular. Still looking into this...

@averyvery
Copy link

Ah, my fix was to just create an empty stub and map to it:

export default {};
module.name_mapper='\(react-redux\)' -> '<PROJECT_ROOT>/flow/GeneralStub.js.flow'

@ericmasiello
Copy link

@averyvery can you give a bit more detail on your approach? where did you put these files?

@averyvery
Copy link

@ericmasiello sure:

// flow/GeneralStub.js.flow
export default {};

// .flowconfig
module.name_mapper='\(react-redux\)' -> '<PROJECT_ROOT>/flow/GeneralStub.js.flow'
module.name_mapper='\(immutable\)' -> '<PROJECT_ROOT>/flow/GeneralStub.js.flow'

@truemagic-coder
Copy link

Also works:
module.name_mapper='(react-redux)' -> 'empty/object'
module.name_mapper='(immutable)' -> 'empty/object'

@hipertracker
Copy link

What about https://github.com/flowtype/flow-typed ?

@reduxjs reduxjs deleted a comment from thisiskylierose Aug 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants