夏明

There is only one thing in the world worse than being talked about, and that is not being talked about.

M1 Mac 配置前端开发环境

2021-08-28


安装Xcode

直接在App Store 搜索Xcode安装即可。

安装homebrew

把终端切换到bash

bash

进入官网下载脚本文件

https://brew.sh

替换镜像源(中科大)

https://mirrors.ustc.edu.cn/homebrew-core.git
https://mirrors.ustc.edu.cn/linuxbrew-core.git
https://mirrors.ustc.edu.cn/brew.git

在bash终端运行此脚本

/bin/bash brew_install

安装完成后退出bash

exit

在终端打开.zshrc

open ~/.zshrc

添加代码

path=('/opt/homebrew/bin' $path)
export PATH

编译.zshrc

source ~/.zshrc

重启终端

安装nvm

git clone https://gitee.com/mirrors/nvm.git ~/.nvm
cd ~/.nvm
git checkout `git describe --abbrev=0 --tags`

解决commond not found:nvm

cd ~/.nvm
touch .bash_profile
open .bash_profile

添加代码

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

编译.bash_profile

source .bash_profile

重启终端

将配置添加到.zshrc中

打开.zshrc

open ~/.zshrc

添加代码

export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ]  && . "$NVM_DIR/nvm.sh"

编译.zshrc

source ~/.zshrc

重启终端

使用nvm安装node

查看目前可以安装的版本

nvm ls-remote

安装node

nvm install v14.17.5