1、卸载brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
2、安装brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/huwei1024/HomebrewCN/raw/master/Homebrew.sh)"
回车运行,按照提示运行下去就可以了;
做完上面的傻瓜式操作,理论上就OK了,但是我这边出现了安装完后用不了的错误;
command not found : brew
经过检查后发现,是因为M1芯片的包安装位置不在是以前的/usr/local/ 而是/opt/homebrew,所以要将配置文件里的环境变量改过来;
-
1、修改环境变量
vim ~/.zshrc -
2、编辑(.zshrc文件)如果有旧的环境就修改,没有就新增
# HomeBrew export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles export PATH=/opt/homebrew/bin:$PATH export PATH=/opt/homebrew/sbin:$PATH # HomeBrew END -
3、生效环境变量
source ~/.zshrc -
4、测试
brew -v -
5、完成
3、安装node
-
1、m1不支持node15以上的版本,我这边选择node10版本;
brew install node@10
-
2、执行brew install node@10后提示(不是最高版本需要本地配置)
==> Downloading mirrors.aliyun.com/homebrew/ho… ######################################################################## 100.0% ==> Pouring node@10-10.21.0.catalina.bottle.tar.gz ==> Caveats node@10 is keg-only, which means it was not symlinked into /opt/homebrew,because this is an alternate version of another formula.
If you need to have node@10 first in your PATH run: echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"' >> /Users/kelin/.bash_profile
For compilers to find node@10 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/node@10/lib" export CPPFLAGS="-I/opt/homebrew/opt/node@10/include" ==> Summary 🍺 /opt/homebrew/Cellar/node@10/10.21.0: 4,302 files, 54.0MB
-
3、关联node10版本
forum-front kelin$ brew link node@10 Warning: node@10 is keg-only and must be linked with --force
If you need to have this software first in your PATH instead consider running: echo 'export PATH="/opt/homebrew/opt/node@10/bin:$PATH"' >> /Users/kelin/.zshrc
-
4、执行强制关联低版本命令 :brew link --force --overwrite node@10
brew link --force --overwrite node@10
-
5、将配置写到配置文件
echo 'export PATH="/opt/homebrew/opt/node@10/bin:$PATH"' >> /Users/kelin/.zshrc
-
6、生效环境变量
source ~/.zshrc
-
7、查看修改后的版本
node -v v10.21.0