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

无法打开React Native应用:@stripe/stripe-react-native钩子文件缺失报错

解决React Native更换Stripe依赖后构建失败的问题
  • 彻底清理依赖与缓存
    删除旧依赖文件、锁文件,清空包管理器缓存后重新安装:

    rm -rf node_modules
    rm package-lock.json yarn.lock
    npm cache clean --force
    npm install
    

    (如果用yarn,把最后两句换成yarn cache clean和yarn install)

  • 匹配Stripe包与React Native版本
    不同版本的@stripe/stripe-react-native对React Native版本有要求,若你的RN版本较低,需安装适配的旧版本:

    npm install @stripe/stripe-react-native@^0.23.0
    

    具体适配版本可查看该包README里的版本兼容说明。

  • 清理平台构建缓存

    • iOS端:
      cd ios
      pod deintegrate
      pod install
      rm -rf build
      
    • Android端:
      cd android
      ./gradlew clean
      
  • 移除旧Stripe依赖的残留代码
    全局搜索项目中所有tipsi-stripe相关的导入、调用代码,全部替换为@stripe/stripe-react-native的对应写法。比如旧的import { Stripe } from 'tipsi-stripe'要换成新包的import { useStripe } from '@stripe/stripe-react-native',残留的旧代码会导致构建时查找不存在的文件。

  • 重置Metro缓存并重启服务
    关闭当前Metro服务器,执行以下命令重启:

    npx react-native start --reset-cache
    

内容的提问来源于stack exchange,提问作者Muhammad Saqib Noor

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 12:25:13