为什么我在 Bare Bones 应用程序中收到“无法找到 Realm 二进制文件”?

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

我创建了一个简单的博览会项目来测试 Realm 并继续得到“无法找到 Realm 二进制文件”。我已经尝试了文档中提供的所有可能的解决方案,但均无济于事。

这是我的整个 App.js 文件:

import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View, TouchableOpacity } from "react-native";
import Realm from 'realm';

import SupplierProductSchema from './models/SupplierContactModel';

const [realm, setRealm] = React.useState(null);
const [supplierProducts, setSupplierProducts] = React.useState([]);

export default function App() {
  // Get List of Products
  useEffect(() => {
    (async () => {
      // initialize realm...
      const realm = await Realm.open({
        path: 'worksiderealm',
        schema: [SupplierProductSchema],
      }).then(realm => {
        // load data in the database...
        const supplierProducts = realm.objects('SupplierProduct');

        // set variable for tasks read from database
        setSupplierProducts([...supplierProducts]);

        // get realm instance to use later in app
        setRealm(realm);

        // set up listener to update task list when the
        // data is updated
        try {
          supplierProducts.addListener(() => {
            setTasks([...supplierProducts]);
          });
        } catch (error) {
          console.error(`Error updating SupplierProducts: ${error}`);
        }
      });
    })();
  }, []);

  return (
    <View className="flex-1 justify-center items-center bg-black">
      <TouchableOpacity className="bg-teal-500 p-3 rounded-lg">
        <Text className="text-white text-xl font-bold">
          Tailwind and Realm Test
        </Text>
      </TouchableOpacity>
      <StatusBar style="light" />
    </View>
  );
}


这是我的模型:

import Realm from 'realm';

export const SupplierProductSchema = {
    name: "SupplierProduct",
    properties: {
      _id: { type: Number },
      supplierProduct_id: { type: Number },
      supplier: { type: String, required: true },
      category: { type: String, required: true },
      product: { type: String, required: true },
      status: { type: String },
      statusdate: { type: Date },
      comment: { type: String },
    },
    primaryKey: '_id',
  };

package.json

{
  "name": "realmtailwindcssapp",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/webpack-config": "^19.0.0",
    "@realm/react": "^0.6.2",
    "expo": "~49.0.15",
    "expo-dev-client": "^2.4.12",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "^1.7.1",
    "nativewind": "^2.0.11",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "^0.72.7",
    "react-native-get-random-values": "^1.9.0",
    "react-native-web": "~0.19.6",
    "realm": "^12.3.0",
    "twrnc": "^3.6.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "sharp-cli": "^4.1.1",
    "tailwindcss": "^3.3.2"
  },
  "private": true
}


应用程序加载,然后我收到以下消息: 错误:找不到 Realm 二进制文件。请参阅我们的故障排除指南:https://www.mongodb.com/docs/realm-sdks/js/latest/#md:troubleshooting-missing-binary,js引擎:hermes

在设置过程中我执行了以下操作: npm 安装领域 npm 我@realm/react

npm install --save-dev Sharp-cli@^2.1.0 npx 展会预建

mongodb realm
1个回答
0
投票

你找到解决办法了吗? 我也有同样的困难。

© www.soinside.com 2019 - 2024. All rights reserved.