mac装机

315 阅读1分钟

安装brew

  1. /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  2. 选择源,如1
  3. 执行全部完毕brew install wget 安装wget
  4. brew install git 安装git

安装nvm

  1. 下载nvm安装包 git clone https://github.com/nvm-sh/nvm.git
  2. 进入nvm目录 cd ~/nvm
  3. 查看当前是否有.bash_profile命令
    • 如果没有 创建.bash_profile命令,Terminal中输入:touch .bash_profile
    • 如果有 打开.bash_profile命令,Terminal中输入:open .bash_profile
  4. 把以下内容复制到.bash_profile
 export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
  1. 保存关闭,或者在Terminal中输入:source .bash_profile
  2. 检查是否安装成功 nvm -v 如果安装成功 则显示版本号
  3. 以上步骤创建完,如果发现新开一个Terminal窗口,nvm提示not found的话:
1. 输入: vi ~/.zshrc
2. 按i进入编辑模式
3. 在文件里加入 source ~/nvm/.bash_profile
4. 按下esc
5. shift+: 然后输入wq保存即可
  1. 安装完成,再nvm install 具体node 版本即可

github访问过慢,配置hosts文件

  1. 打开hosts文件mac电脑目录为 /etc/hosts
  2. 直接打开可能不允许修改,在黑窗口使用vim打开然后i即可编辑
  3. 进入 查询ip页面
  4. 分别搜索github.global.ssl.fastly.netgithub.com
  5. 然后将ip与url放在hosts文件里面
  6. 按下esc键,然后shift+:,输入wq!回车保存即可
  7. 有时候配置以后还是很慢,在命令行输入ping github.com 等几秒control+c,然后再访问即可