This error occurs when installing node using brew
Guess the reason:
应该是homebrew没有找到git路径,因此我们需要配置一下
ps: Most of the reference materials are directly git binding homebrew under the usr/local/ path, here we need to configure our own local path
solution
-
Find Homebrew installation location
- Here I am using
find / -name "homebrew-cask"
- Find the following similar paths
- It is recommended to open this directory to see if it is the following three directories at the same level as this directory
- Here I am using
-
git bind homebrew path
- git config --global --add safe.directory
自己的homebrew-core目录
- git config --global --add safe.directory
自己的homebrew-cask目录
- git config --global --add safe.directory
-
Check to see if the addition is complete
git config --global --list
, so the configuration is successful.
ps: If you have configured other directories before, it is recommended to find .gitconfig and delete others.
Find the gitconfig command:git config --global --list --show-origin