「本文已参与 周末学习计划,点击查看详情 」
近期很多童鞋都使用上 mac pro m1 ,香不香我不知道,但是在最基本的环境配置上还是有点曲折。经过几次折腾写下完整步骤,不走弯路!
安装 xcode-select
运行命令
xcode-select --install
复制代码
这个安装完成之后,git 也会附带安装。
注意事项
如果报【不能安装该软件】,则可以去 https://developer.apple.com/download/more/开发者网站下载相应版本的CommandLineTools工具
安装 homebrew
运行命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# 如果下载速度太慢或下载失败,可以使用下面的gitee的镜像地址
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
复制代码
安装 nvm
运行命令
# 安装nvm
brew install nvm
## 配置nvm环境变量
vi ~/.bash_profile
# 然后添加以下内容
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
# :wq 保存退出后再运行以下命令
source ~/.bash_profile
# 如果使用zsh,则需要将 source ~/.bash_profile 放到 .zshrc 中
# 然后运行以下命令
source ~/.zshrc
复制代码
安装 node
运行命令
nvm install node # 安装最新的稳定版本
nvm install 12.21.1 # 安装指定的版本
nvm ls # 列出已安装的 node
nvm use 12.21.1 # 使用某个版本的 node
nvm alias default 12.21.1 # 设置默认 node 版本的别名
复制代码
注意事项
安装 node16 以下的版本可能会报错,可以使 Rosetta 打开终端重新运行,点击访达->应用程序->终端->显示简介->勾选使用 Rosetta 打开,然后重新运行终端
然后再去 nvm install xxx
安装 yarn
运行命令
# 全局安装yarn
npm install -g yarn
复制代码
配置国内镜像
运行命令
# 配置node-sass、node-gyp、electron等包的镜像地址
npm install -g mirror-config-china
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END