If I have a file with
/* @flow */
var ReactRouter = require('react-router');
flow will fail with:
path/to/file:2 lib
Required module not found
Changing the main property from lib in the package.json of react-router to be lib/index makes it work.
What is the underlying issue here? Seems like flow doesn't understand node/npm's index.js convention.
@mjackson yes that is my current guess.
I ran into this issue as well. After some testing, it seems that flow does understand index.js convention when requiring (relative) folders in code (i.e. require('./dir')), but it does not support the convention in main property of package.json.
It seems that the issue is fixed 0.5.0
Please reopen if this is still an issue.
I see this error again with Flow 0.16.0. Seems to be tracked by #654 now.
@samwgoldman, I'm seeing this in Flow 0.22.0 with the react-router package, which specifies its 'main' in the package json as just 'lib' instead of 'lib/index.js'.
Just upgraded from 0.21 -> 0.22 and seeing this bug.
EDIT: 0.22 started parsing .json files, so I added a regex to exclude them, which excluded package.json which caused the issue.
This was fixed in 0.22.1, right?
i'm seeing this error with flow-bin 0.29. every import that I do from node_modules is failing.
just ran this test:
mkdir -p test/node_modules/foo/lib
pushd test
printf "// @flow\n\nmodule.exports = 'hello';\n" > node_modules/foo/lib/index.js
echo '{"name": "foo", "main": "lib"}' > node_modules/foo/package.json
printf "// @flow\n\n(require('foo'): number);\n" > index.js
touch .flowconfig
flow check
popd
and got this:
$ flow check
index.js:3
3: (require('foo'): number);
^^^^^^^^^^^^^^ string. This type is incompatible with
3: (require('foo'): number);
^^^^^^ number
Found 1 error
so I think it's working now (v0.32)
Just bumped into this again. Do NOT add this to your .flowconfig:
[ignore]
.*/node_modules/.*\.json$