Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flow erroring "cant resolve module" when importing node modules

I recently added this to my flow config due to tons of errors related to node modules that flow picks up

[ignore]
.*/node_modules/.*

This solved those errors, but introduced new one. Now every module I import results in an error where flow says it can't resolve it, hence leading me to think this is due to that ignore rule I added.

Is there a way to fix this because here removing this line just introduces different kind of error, keeping it in still makes it error.

like image 753
Ilja Avatar asked Oct 24 '17 09:10

Ilja


2 Answers

It's a little late now, but for anyone stumbling along this question in the future: you shouldn't ignore your node_modules folder. Flow is supposed to read from that folder and analyze the files inside it.

like image 57
James Kraus Avatar answered Nov 05 '22 22:11

James Kraus


Actually this is because of the module has no typed definitions. So we can just use flow-typed to create any definition.

  1. Run yarn global add flow-typed to install flow-typed globally.

  2. Go to project folder: flow-typed install

  3. Close your terminal and try to run npm run flow again. That's it.

Ref: https://github.com/facebook/flow/issues/5935

like image 35
davychhouk Avatar answered Nov 05 '22 23:11

davychhouk