错误:不变违规:TurboModuleRegistry.getEnforcing(...):找不到“RNDocumentPicker”

问题描述 投票:0回答:2

我的 React Native 项目中收到以下错误:

错误:不变违规:TurboModuleRegistry.getEnforcing(...):找不到“RNDocumentPicker”。验证此名称的模块是否已在本机二进制文件中注册。js 引擎:hermes

在我的项目中包含 import DocumentPicker from 'react-native-document-picker' 后,这种情况就开始发生了(我使用 yarn add react-native-document-picker 安装了包)。 我已在下面包含我的 package.json 内容:

{
  "name": "ezeap",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.18.1",
    "@react-native-community/datetimepicker": "^7.1.0",
    "@react-native-community/netinfo": "^9.3.10",
    "@react-native-material/core": "^1.3.7",
    "@react-native-picker/picker": "^2.4.10",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/stack": "^6.3.16",
    "@rneui/base": "^4.0.0-rc.7",
    "@rneui/themed": "^4.0.0-rc.7",
    "aws-amplify": "^5.2.5",
    "aws-amplify-react-native": "^7.0.2",
    "check-peer-dependencies": "^4.2.0",
    "expo": "~48.0.15",
    "expo-linear-gradient": "~12.1.2",
    "expo-status-bar": "~1.4.4",
    "graphql": "15.8.0",
    "history": "5.3.0",
    "link": "^1.5.1",
    "ra-core": "4.11.3",
    "ra-data-graphql": "^4.10.1",
    "react": "18.2.0",
    "react-dom": "18.3.0-next-fecc288b7-20221025",
    "react-hook-form": "7.45.0",
    "react-native": "^0.71.7",
    "react-native-date-picker": "^4.2.13",
    "react-native-document-picker": "^9.0.1",
    "react-native-gesture-handler": "^2.9.0",
    "react-native-keychain": "^8.1.1",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-loading-spinner-overlay": "^3.0.1",
    "react-native-paper": "^5.8.0",
    "react-native-phone-call": "^1.2.0",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-vector-icons": "^9.2.0",
    "react-redux": "^8.1.0",
    "react-router": "6.13.0",
    "react-router-dom": "6.13.0",
    "redux": "^4.2.1",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.4.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

我应该采取哪些步骤来解决这个问题?

当我删除与 DocumentPicker 相关的 import 语句时,问题就消失了。 此外,我尝试删除并重新安装 node_modules 文件夹,不幸的是这并没有解决错误。

javascript node.js react-native expo yarnpkg
2个回答
1
投票

尝试使用 "react-native-document-picker": "^8.2.1", 现在


0
投票

我也面临着同样的问题。我的应用程序正在使用 expo,这个解决方案对我有用

npm i react-native-document-picker
npx expo prebuild
npx expo run:android

ios也可以做同样的事情。

此解决方案取自此 Github Issue

供将来参考, 我使用的版本:

 "react-native-document-picker": "^9.1.0",
 "expo": "~49.0.15",
© www.soinside.com 2019 - 2024. All rights reserved.