You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo SQLiteProvider使用时触发报错的问题求助

Expo SQLiteProvider使用时触发报错的问题求助

我第一次尝试用expo-sqlite开发,结果一用SQLiteProvider包裹组件就触发报错,折腾了好几天都没搞定,来求助各位大佬!

报错情况

  • 手机端(Expo客户端运行):弹出警告 Warning: TypeError: Cannot read property 'replace' of undefined
  • Web端构建:直接报模块找不到错误,具体信息如下:
None of these files exist:
* node_modules\expo-sqlite\web\wa-sqlite\wa-sqlite.wasm(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.mjs|.mjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)
* node_modules\expo-sqlite\web\wa-sqlite\wa-sqlite.wasm
 20 | import WaSQLiteFactory from './wa-sqlite/wa-sqlite';
 21 | // @ts-expect-error wasm module is not typed
> 22 | import wasmModule from './wa-sqlite/wa-sqlite.wasm';
    | ^
 23 | import {
 24 |   type SQLiteWorkerMessage,
 25 |   type SQLiteWorkerMessageType,

我已经尝试过的方法

  • 反复删除node_modules和package-lock.json后重新执行npm install,问题依旧
  • 尝试更新各个依赖包的版本,结果反而引出更多新问题
  • 只要把SQLiteProvider注释掉,代码就能正常运行,但一加回去就立刻报错

我的代码

import { library } from "@fortawesome/fontawesome-svg-core";
import { fab } from "@fortawesome/free-brands-svg-icons";
import { far } from "@fortawesome/free-regular-svg-icons";
import { fas } from "@fortawesome/free-solid-svg-icons";
import { SQLiteProvider } from 'expo-sqlite';
import { View } from "react-native";
import { checkIfDbExists } from "../backend/sql";
import HomeScreen from "../components/screens/HomeScreen";
import { styling } from "../styles/styles";

library.add(fab, fas, far)

const App = () => {
  const styles = styling();
  return (
    <SQLiteProvider databasename="checkbook.db" onInit={checkIfDbExists} >
      <View style={styles.container}>
        <HomeScreen />
      </View>
    </SQLiteProvider>
  );
};

export default App;

我现在完全摸不着头绪,感觉代码本身没什么问题,但就是一用Provider就崩,有没有大佬遇到过类似问题,或者能帮我排查一下原因?感谢各位!

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 13:30:28