react-native-documents / document-picker

Document Picker for React Native
https://react-native-documents.github.io/
MIT License
1.35k stars 441 forks source link

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNDocumentPicker' could not be found. #655

Closed xkomiks closed 1 year ago

xkomiks commented 1 year ago

Question

I'm new to React native. Sorry if this is something obvious I get an error on IOS

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNDocumentPicker' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

What u

What I've done

npx create-expo-app my-app. Install yarn add react-native-document-picker.

App.tsx

import React from 'react';
import { Button, StyleSheet, View } from 'react-native';
import DocumentPicker from 'react-native-document-picker';

const App = () => {
  const selectDoc = async () => {
    try {
      const doc = await DocumentPicker.pick();
      console.log(doc);
    } catch (error) {
      if (DocumentPicker.isCancel(error)) {
        console.log('User cancelled the upload', error);
      } else {
        console.log(error);
      }
    }
  };

  return (
    <View style={styles.container}>
      <Button
        title="Select document"
        onPress={selectDoc}
      />
    </View>
  );
};

If you need a screenshot of error image

xkomiks commented 1 year ago

When I did console.log it turned out that DocumentPicker is undefined. This is strange because it is installed and is in node_modules

xkomiks commented 1 year ago

It didn't help me much https://github.com/rnmods/react-native-document-picker#expo.

vonovak commented 1 year ago

Hello and thanks for asking. Please try version 8 for now, it has the same feature set and should work for you. I'll try to look into this later

vonovak commented 1 year ago

Hello and thanks for asking, please follow the steps in readme. When I did

npx create-expo-app doc-picker-bug
cd doc-picker-bug/
npm i react-native-document-picker
npx expo prebuild
npx expo run:ios

and used your code, it worked.

Thank you 🙂

nandinicbit1981 commented 1 year ago

I am noticing the same issue for React native version - 0.71. We are using standalone react native app. I have followed the cleanup steps mentioned above including clean pod install, but that did not help.

MFrat commented 10 months ago

Still same issue. Version: 9.1.0.

kskby commented 9 months ago

Hi. Try these commands. They helped me

./gradlew clean npm start --reset-cache

ZakRab commented 5 months ago

I'm getting the same error but im not using expo, is there another way to get this working with just yarn?