使用brew安装node时发生此错误
猜测原因:
应该是homebrew没有找到git路径,因此我们需要配置一下
ps: 查阅资料大多都是直接git绑定usr/local/路径下面的homebrew,这里我们需要配置自己本地的路径
解决方案
-
查找Homebrew安装位置
- 这里我使用的是
find / -name "homebrew-cask"
- 找到以下类似路径
- 这里建议打开此目录看下与此目录同级是否为以下三个目录
- 这里我使用的是
-
git绑定homebrew路径
- git config --global --add safe.directory
自己的homebrew-core目录
- git config --global --add safe.directory
自己的homebrew-cask目录
- git config --global --add safe.directory
-
查看是否完成添加
git config --global --list
这样就算是配置成功了。
ps:如果之前有配置过其他的directory,建议找到.gitconfig删除其他的
查找gitconfig命令:git config --global --list --show-origin