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

首次搭建Expo React Native项目遇Operation not permitted权限错误求助

解决Expo项目Watchman权限错误的方案

1. 修复Watchman状态目录权限

首先处理Watchman核心权限问题:

  • 执行 watchman version 确认当前运行用户
  • 给Watchman的状态目录设置正确所有者:
    sudo chown -R $(whoami):staff /opt/homebrew/var/run/watchman
    
  • 重置Watchman缓存状态:
    watchman watch-del-all
    watchman shutdown-server
    

2. 修正项目目录权限(禁止用sudo启动npm)

绝对不要用sudo运行npm start,这会导致权限上下文混乱。普通用户启动时报错的话:

  • 给项目目录设置正确所有者:
    sudo chown -R $(whoami):staff ./
    
  • 确保目录具备读写权限:
    chmod -R 755 ./
    

3. 重装Watchman(以上方案无效时)

  • 卸载Watchman:
    brew uninstall watchman
    
  • 删除残留状态目录:
    rm -rf /opt/homebrew/var/run/watchman
    
  • 重新安装:
    brew install watchman
    
  • 安装完成后重复步骤1的重置操作

4. 确认Watchman配置

确保项目根目录的.watchmanconfig配置正确(没有则新建):

{
  "ignore_dirs": ["node_modules"]
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 23:01:09