Expo Prebuild失败报错:paths[1]需为字符串,收到Object实例
Expo Prebuild 报错与字体加载问题
预构建报错详情
执行npx expo prebuild时触发以下错误:
C:\Users\spippolator\React\myApp> npx expo prebuild (node:25332) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) √ Created native directory | reusing /android √ Updated package.json | no changes × Prebuild failed TypeError [ERR_INVALID_ARG_TYPE]: [android.dangerous]: withAndroidDangerousBaseMod: The "paths[1]" argument must be of type string. Received an instance of Object ...(报错栈省略)
同时构建时还会收到字体警告:
WARN fontFamily "font1" is not a system font and has not been loaded through expo-font.
当前字体配置
代码中加载方式
使用useFonts钩子加载字体:
const [fontsLoaded] = useFonts({ 'font1': require('./assets/fonts/firstfont.otf'), 'font2': require('./assets/fonts/secondfont.ttf'), ... });
也曾尝试通过import引入字体后传入useFonts,结果一致。
app.json配置
- android配置中包含
fonts字段 - plugins数组里配置了
expo-font插件及字体列表
已尝试的排查操作
- 修改字体文件路径
- 调整字体声明方式(require/import)
- 更新Expo到最新版本
- 新建空白项目测试,问题复现
请求技术帮助定位问题根源并解决。
内容的提问来源于stack exchange,提问作者Nicola
相关产品推荐
相关产品推荐

