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

Expo React Native本地通知报错:_expoModulesCore.uuidv4 is not a function

解决 Expo React Native 本地通知报错“_expoModulesCore.uuidv4 is not a function”

问题原因

该错误是因为 expo-notifications 依赖 expo-modules-core 提供的 uuidv4 函数,但你当前安装的 expo-modules-core@1.8.0 与 Expo 49 版本不兼容,导致该函数无法正常调用。

解决方案

1. 回退到 Expo 49 兼容的 expo-modules-core 版本

Expo 49 官方适配的 expo-modules-core 版本为 1.5.9,手动安装更高版本会引发依赖冲突:

# 卸载当前版本
npm uninstall expo-modules-core
# 安装兼容版本
npm install expo-modules-core@1.5.9
# 清除 Expo 缓存并重启服务
expo start --clear

2. 清除缓存并重建依赖

如果上述步骤无效,尝试彻底清除缓存并重启:

expo start --clear

若使用开发构建(Development Build),需重新构建原生应用:

# 根据平台选择 android 或 ios
eas build --profile development --platform android

3. 清理冗余依赖(可选)

你安装了 uuid 和 uuid-random 两个包,但 expo-notifications 会直接使用 expo-modules-core 内置的 UUID 功能,移除这些冗余包可减少潜在冲突:

npm uninstall uuid uuid-random

额外优化

你在 notification.js 和 App.js 中重复调用了 Notifications.setNotificationHandler,保留其中一处即可(建议放在 App.js 全局初始化)。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 22:39:50