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

React Native Expo项目遇metro-file-map: Watchman爬取失败求助

解决Watchman同步超时导致Metro启动失败的问题

以下是针对你遇到的问题的进阶解决方案:

  • 彻底清理环境并重启依赖
    执行完整的清理流程,覆盖缓存和依赖:

    watchman watch-del-all
    watchman shutdown-server
    rm -rf node_modules
    npm cache clean --force
    npm install
    

    完成后重新启动你的Expo项目。

  • 更新Watchman到最新版本
    先查看当前版本:

    watchman --version
    

    根据你的系统执行更新命令:

    • macOS(Homebrew):brew upgrade watchman
    • Ubuntu/Debian:sudo apt update && sudo apt upgrade watchman
    • Windows(Chocolatey):choco upgrade watchman
  • 优化Watchman配置
    修改项目根目录的.watchmanconfig文件,增加超时设置并忽略冗余目录:

    {
      "ignore_dirs": ["node_modules"],
      "settle": 2000
    }
    

    这个配置能减少Watchman的监听负载,同时延长同步超时时间。

  • 临时绕过Watchman
    如果紧急需要继续开发,可以强制Metro使用Node原生文件监听,启动命令改成:

    expo start --no-watchman
    
  • 检查系统权限
    确认Watchman有访问项目目录的权限,比如macOS用户可以去「系统设置-隐私与安全性-文件与文件夹」中,给Watchman添加项目文件夹的访问权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.05 17:40:31