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

Expo集成Sentry时无法解析@sentry/react-native/expo插件问题

解决Expo集成Sentry时插件解析失败的问题

修复步骤

1. 修正插件路径

新版本的@sentry/react-native已将Expo插件路径从@sentry/react-native/expo调整为@sentry/react-native/expo-plugin。打开你的app.json或app.config.js,修改插件配置如下:

"plugins": [
  "expo-localization",
  [
    "expo-build-properties",
    {
      "ios": { "newArchEnabled": false },
      "android": { "newArchEnabled": false }
    }
  ],
  [
    "@sentry/react-native/expo-plugin",
    {
      "organization": "myslag",
      "project": "myproject"
    }
  ]
]

2. 重装依赖并清理缓存

依赖安装不完整或缓存可能导致解析异常,执行以下命令:

# 卸载现有Sentry依赖
npm uninstall @sentry/react-native
# 重新安装适配Expo的最新版本
npx expo install @sentry/react-native@latest
# 清理Expo预构建缓存
npx expo prebuild --clean
# 清空开发服务器缓存并重启
npx expo start --clear

3. 排查Ignite模板的依赖冲突

Ignite模板可能自带部分配置,检查package.json里是否存在重复的Sentry相关依赖,确保只有@sentry/react-native这一项,且版本与你的Expo SDK版本匹配。

4. 手动指定插件绝对路径(备选方案)

如果上述步骤无效,尝试直接指定插件在node_modules里的绝对路径:

"plugins": [
  // 其他插件...
  [
    "./node_modules/@sentry/react-native/expo-plugin",
    {
      "organization": "myslag",
      "project": "myproject"
    }
  ]
]

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 07:03:13