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

安装react-native-shadow包后报错:Cannot find module 'react-native-svg' from 'BoxShadow.js'

解决react-native-shadow依赖react-native-svg缺失的错误

这个报错是因为react-native-shadow依赖react-native-svg包,但安装react-native-shadow时没有自动安装这个依赖项,所以会提示找不到模块。按下面步骤解决:

  • 先安装react-native-svg:

    • 使用npm:npm install react-native-svg --save
    • 使用yarn:yarn add react-native-svg
  • 版本适配处理:

    • 如果你用的是React Native 0.60及以上版本,包会自动完成链接,不用额外操作;
    • 要是版本低于0.60,需要手动执行链接命令:react-native link react-native-svg
  • 重启项目生效:

    • 先关掉当前运行的Metro服务,然后清除缓存重启:npm start --reset-cache(yarn用户用yarn start --reset-cache)
    • 最后重新编译运行iOS或Android项目即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 05:32:36