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

Expo(Web)环境下无法运行Lottie组件的问题求助

问题解决指南

问题原因

你遇到的仓库不存在报错,确实是因为@lottiefiles/react-lottie-player的GitHub仓库地址变更或已迁移,导致expo install命令无法拉取到包资源。同时Expo官方文档的简易说明可能存在混淆——Expo自身集成的Lottie组件其实是expo-lottie,而非第三方的@lottiefiles/react-lottie-player。

解决方案

方案一:使用Expo官方集成的Lottie组件(推荐)

这是最适配Expo项目的方式:

  1. 清理残留的错误依赖(如果之前尝试安装过):
    npm uninstall @lottiefiles/react-lottie-player
    
  2. 安装Expo官方的Lottie包:
    npx expo install expo-lottie
    
  3. 在代码中正确导入并使用:
    import { LottieView } from 'expo-lottie';
    
    // 示例用法
    <LottieView
      source={require('./assets/animation.json')}
      autoPlay
      loop
    />
    

方案二:手动安装第三方Lottie Player包

如果确实需要使用@lottiefiles/react-lottie-player,可以绕过expo install直接用npm安装,同时确保使用HTTPS而非SSH拉取:

  1. 执行以下命令安装:
    npm install @lottiefiles/react-lottie-player --registry=https://registry.npmjs.org/
    
  2. 安装完成后,按照包的官方文档导入使用即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 04:17:04