Skip to content
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

Cannot find module #9

Closed
rgbedin opened this issue Feb 19, 2021 · 21 comments · Fixed by #10 or #32
Closed

Cannot find module #9

rgbedin opened this issue Feb 19, 2021 · 21 comments · Fixed by #10 or #32
Assignees
Labels
bug Something isn't working

Comments

@rgbedin
Copy link

rgbedin commented Feb 19, 2021

I am sorry if that seems like a silly thing to ask, but I have tried all sorts of things to make the import work with no success:

Cannot find module '@stream-io/flat-list-mvcp' or its corresponding type declarations. ts(2307)

I inspected the node_modules/@stream-io/flat-list-mvcp and all the files are there. I realized they are using a index.ios.tsx and index.android.tsx. Do I need any special configurations in my RN project to make it able to read those? I am currently using react-native: 0.63.3. Thank you!

Screen Shot 2021-02-19 at 5 40 17 PM

@vishalnarkhede
Copy link
Collaborator

@rgbedin Is this only a typescript issue or are you not able to use FlatList at all from this package?

@rgbedin
Copy link
Author

rgbedin commented Feb 20, 2021

@vishalnarkhede It seems to be a Typescript issue; however it should be able to find the types. Are there any project-specific configurations (tsconfig.json) that I should be aware of? Thank you for your help!

@vishalnarkhede
Copy link
Collaborator

@rgbedin checking..

@vishalnarkhede vishalnarkhede linked a pull request Feb 21, 2021 that will close this issue
@vishalnarkhede vishalnarkhede added the bug Something isn't working label Feb 21, 2021
@vishalnarkhede vishalnarkhede self-assigned this Feb 21, 2021
@vishalnarkhede
Copy link
Collaborator

@rgbedin fixed in v0.0.6

@rgbedin
Copy link
Author

rgbedin commented Feb 21, 2021

Thanks!

@jbernhardt23
Copy link

I'm facing this same issue, I'm not using Typescript and running "react-native": "~0.63.3. All files are there and I'm able to use the Flatlist component but for some reason the linter is complaining.

Version 0.10.1

image

@vishalnarkhede
Copy link
Collaborator

Let me take a look and get back :)

@jbernhardt23
Copy link

Let me take a look and get back :)

@vishalnarkhede any updates on this?

@vishalnarkhede
Copy link
Collaborator

@jbernhardt23 Unfortunately I am not able to reproduce this. Can you check if you can see this file?
node_modules/@stream-io/flat-list-mvcp/lib/typescript/src/index

@jbernhardt23
Copy link

jbernhardt23 commented Apr 30, 2021

@vishalnarkhede It is there. I also see that the following in the FlastList.android.d.ts

image

image

@jbernhardt23
Copy link

@vishalnarkhede Would it have something to do with the fact that my project is not using yarn ?

@jbernhardt23
Copy link

Hey @vishalnarkhede have you been able to look at this? Thanks

@roryabraham
Copy link

I'm running into a similar issue, but only in jest unit tests. react-native-bidirectional-infinite-scroll is rendering fine and I'm not seeing the error at runtime.

 FAIL  tests/unit/loginTest.js
  ● Test suite failed to run

    Cannot find module '@stream-io/flat-list-mvcp' from 'node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/BidirectionalFlatList.js'

    Require stack:
      node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/BidirectionalFlatList.js
      node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/index.js
      ...
      ...
      
     at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
     at Object.<anonymous> (node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/BidirectionalFlatList.tsx:10:1)

@jbernhardt23
Copy link

@roryabraham right, it works fine runtime but the unit tests

@pr4deep94
Copy link

Hi I am getting similar issue in expo web browser
./node_modules/react-native-bidirectional-infinite-scroll/lib/module/BidirectionalFlatList.js:10
Module not found: Can't resolve '@stream-io/flat-list-mvcp'

@Surinder1922
Copy link

Hi guys, I am also facing issue in unit tests can you please provide some solution . Many thanks in advance.

(Its working perfectly runtime)

Test suite failed to run

   Cannot find module '@stream-io/flat-list-mvcp' from 'node_modules/stream-chat-react-native/src/index.js'

   Require stack:
     node_modules/stream-chat-react-native/src/index.js

@Surinder1922
Copy link

I'm running into a similar issue, but only in jest unit tests. react-native-bidirectional-infinite-scroll is rendering fine and I'm not seeing the error at runtime.

 FAIL  tests/unit/loginTest.js
  ● Test suite failed to run

    Cannot find module '@stream-io/flat-list-mvcp' from 'node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/BidirectionalFlatList.js'

    Require stack:
      node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/BidirectionalFlatList.js
      node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/index.js
      ...
      ...
      
     at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
     at Object.<anonymous> (node_modules/react-native-bidirectional-infinite-scroll/lib/commonjs/BidirectionalFlatList.tsx:10:1)

Hey @rgbedin , Are you able to get any solution for it, I have tried various configuration by adding paths in jest config but nothing works.

@Maxim-Filimonov
Copy link

Maxim-Filimonov commented Jan 8, 2022

@Surinder1922 & @roryabraham do you have javascript only project? I have JS non TS project and facing the same issue with jest.

I have a feeling it has something to do with missing index.js file.

cat node_modules/@stream-io/flat-list-mvcp/package.json| grep main
"description": "maintainVisibleContentPosition support for Android react-native",
"main": "lib/commonjs/index",
ls node_modules/@stream-io/flat-list-mvcp/lib/commonjs
FlatList.android.js FlatList.js ScrollView.android.js ScrollView.js index.js.map useMvcpTuner.js.map
FlatList.android.js.map FlatList.js.map ScrollView.android.js.map ScrollView.js.map useMvcpTuner.js

EDIT:
After fiddling with the package found that build script has this line for some reason: rm lib/commonjs/index.js
After removing it and running build again managed to run jest without this issue.
Though a new one appears:

Invariant Violation: __fbBatchedBridgeConfig is not set, cannot invoke native modules

  at invariant (node_modules/@stream-io/flat-list-mvcp/node_modules/invariant/invariant.js:40:15)
  at Object.<anonymous> (node_modules/@stream-io/flat-list-mvcp/node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:169:3)
  at Object.<anonymous> (node_modules/@stream-io/flat-list-mvcp/node_modules/react-native/Libraries/TurboModule/TurboModuleRegistry.js:13:23)

@gtcaras
Copy link

gtcaras commented Jan 14, 2022

@Maxim-Filimonov you suggestion worked to resolve my import issues when running jest. I did not run into the new error you mentioned so that may be caused by another issue unrelated to the import itself.

@divonelnc
Copy link

Any idea on how to solve this with expo web?

@finalight
Copy link

i'm still facing this issues, any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
10 participants