react-native-documents/document-picker

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

Closed this issue ยท 8 comments

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

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

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

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 ๐Ÿ™‚

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.

Still same issue. Version: 9.1.0.

Hi. Try these commands. They helped me

./gradlew clean
npm start --reset-cache

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