首次搭建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
相关产品推荐
相关产品推荐

