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

使用Expo的RN Skia Web项目无法添加文本的问题求助

Expo Router + RN Skia Web 文本组件报错问题

报错信息

Uncaught Error
_Image.default.resolveAssetSource is not a function

代码示例

// 文本配置:
const fontSize = 32;
const font = useFont(require('../fonts/Roboto-Light.ttf'), fontSize);

...

<Text
  x={100}
  y={100}
  text="test"
  font={font}
  size={32}
  opacity={100}
/>

复现步骤

  • 执行 npx create-expo-app@latest -e with-router 创建项目
  • 跳过直接安装 @shopify/react-native-skia,改用 expo install @shopify/react-native-skia
  • 执行 yarn setup-skia-web
  • 安装开发依赖:npm install copy-webpack-plugin --save-dev、npm i node-polyfill-webpack-plugin
  • 按照Skia Web官方文档配置webpack.config.js
  • 安装依赖包:yarn add react-native-level-fs、yarn add path-browserify,并在package.json的dependencies字段中添加 "fs": "react-native-level-fs", "path": "path-browserify"
  • 在index.js中使用代码分割方式引入Skia
  • 再次执行 yarn add path-browserify 后,出现以下错误:

Aborted(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0). Build with -sASSERTIONS for more info.

  • 改用CDN方式引入Skia后,添加Text组件时触发最初的_Image.default.resolveAssetSource is not a function错误

内容的提问来源于stack exchange,提问作者Francesco Russo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 18:05:19