【问题标题】:Why "Watchman crawl failed" error in react-native immediately after updating to macOS catalina?为什么在更新到 macOS catalina 后立即在 react-native 中出现“Watchman crawl failed”错误?
【发布时间】:2019-10-10 08:16:02
【问题描述】:

尝试运行react-native run-ios 或从xcode 构建RN 项目,一旦metro bundler 启动,终端就会出现此错误:

Loading dependency graph...jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
  Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
  Error: Watchman error: resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
events.js:183
      throw er; // Unhandled 'error' event
  ^

Error: resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted
    at BunserBuf.<anonymous> (/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/fb-watchman/index.js:95:23)
    at emitOne (events.js:116:13)
    at BunserBuf.emit (events.js:211:7)
    at BunserBuf.process (/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/bser/index.js:292:10)
    at /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/bser/index.js:247:12
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

这在 Catalina 更新之前从未发生过。从一开始,我的项目根目录中就有一个空的守望者配置文件。在更新后的第一次启动时,终端中有一个弹出窗口说一些有关权限的信息,但我不记得确切。在 Visual Studio 代码中我的终端中还有一条通知说“默认 shell 已更改为 zsh”运行 chsh -s /bin/zsh 进行更改,所以我做到了。

我试过了:

  • watchman watch-del-all

  • watchman server-shutdown

  • 从系统首选项->隐私选项卡中添加对终端的完整磁盘访问

  • npm uninstall watchman & npm uninstall -g watchman

【问题讨论】:

  • [将其移至答案,尽管它更像是故障排除]

标签: react-native terminal react-native-android react-native-ios watchman


【解决方案1】:

更新到 Catalina 后我遇到了同样的问题。 Wez Furlong 的回答对我有用,但我必须为 watchman 提供完整的磁盘访问权限才能运行 watchman watch-project 命令而不会出现“不允许操作”错误。作为先前故障排除的一部分,我还提供了对 Xcode 和终端的完整磁盘访问(不确定这是否也有助于修复)。

【讨论】:

  • 最后我从来没有 Wez Furlong 建议删除的 .plist 文件,我重新安装了 watchman,授予对 13 个 watchman 程序之一的完整磁盘访问权限,按照此处的建议运行 watchman watch-project,一切正常。非常感谢
  • 你的项目在哪里?(~或者里面的其他地方~)
  • 这是正确答案。帮我解决了 Catalina 升级后的问题。系统偏好设置 -> 安全和隐私 -> 隐私 -> 全盘访问 -> 启用守望者
【解决方案2】:

要更改 Watchman 对 Documents 文件夹的权限,请在系统偏好设置中的安全和隐私 -> 文件和文件夹下

通过在 Document 文件夹下的列表中检查 Watchman 解决了我的问题

【讨论】:

    【解决方案3】:

    您需要授予对watchman 的磁盘访问权限。为此,您需要:

    • 转到System preferences > Security &amp; Privacy 然后向下滚动
    • 选择Full Disk Access
    • 解锁并点击+按钮添加新应用/工具
    • 在文件夹列表中选择Macintosh HD
    • 同时按此组合shiftCommand.查看所有目录列表
    • 单击opt &gt; brew &gt; bin(MacOS Catalina 的watchman 安装在此文件夹中)|| usr &gt; local &gt; Cellar &gt; Watchman &gt; 21***** &gt; bin(MacOS Monterey这个文件夹安装watchman)
    • 在列表中查找watchman,然后选择它

    我们开始吧,这应该可以解决问题。

    【讨论】:

    • 我在升级到 Mac OS Monterey 后遇到了同样的问题,这解决了我的问题,只是我的守望者位于 usr/local/Cellar
    • 完美运行,谢谢!
    【解决方案4】:

    错误信息表明/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA的权限问题。

    但是,launchd 可能有点时髦,所以我建议:

    $ watchman shutdown-server
    $ launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
    $ rm ~/Library/LaunchAgents/com.github.facebook.watchman.plist
    $ watchman watch-project /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA
    

    看看这是否有效或显示更多上下文。

    交叉链接回我们 GitHub 跟踪器中的问题: https://github.com/facebook/watchman/issues/751

    【讨论】:

    • 结果:Jamess-MacBook-Pro:TicTacWHOA vorousjames$ watchman watch-project /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA { "version": "4.9.0", "error": "resolve_projpath: path /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted"}
    【解决方案5】:

    只需取消选中 Mac 中重复的框即可:

    系统偏好设置 -> 安全和隐私 -> 隐私

    【讨论】:

      【解决方案6】:

      你需要改变一些对我有用的东西。只需遵循以下步骤:

      1. Go to System preferences > Security & Privacy then scroll down.
      2. Select    Full Disk Access.
      3. Look for all watchmen on the list.
      4. check(Mark) all Folders in all watchman files. 
      5. then go to vs code.
      6. rebuilt your code.
      I hope it will work smoothly
      

      【讨论】:

      • 检查列表中的所有守望者文件解决了我的问题,谢谢
      【解决方案7】:

      尝试更改项目的目录。我在桌面上有我的并且收到了那个错误,移动到主文件夹并且错误消失了

      【讨论】:

        【解决方案8】:

        npx react-native start --port=8088 解决了我的问题

        【讨论】:

          【解决方案9】:

          尝试将项目从桌面移动到 Mac 中的用户文件夹

          【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-03-13
          • 1970-01-01
          • 2020-10-25
          • 1970-01-01
          • 2021-10-05
          • 2017-01-02
          • 2020-02-06
          • 1970-01-01
          相关资源
          最近更新 更多