1、首先安装homebrew包管理器,在终端执行以下命令
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
过程中显示没有安装git,根据提示自动安装git,过程会比较长,不想等待的可以去另行查询。
2、安装nvm(node版本工具)
-
从github下载nvm仓库到 ~/目录 地址:github.com/nvm-sh/nvm.…
-
进入 nvm目录中执行install.sh (在终端输入 ./install.sh)等待执行完成
-
mac pro 环境变量的配置 (当不存在 .bash_profile 文件的时候)
-
启动终端Terminal
-
进入当前用户的home目录(/Users/lanhongmei/)
输入cd ~
-
创建.bash_profile
输入touch .bash_profile
-
编辑.bash_profile文件
输入open -e .bash_profile
-
保存文件,关闭.bash_profile
-
更新刚配置的环境变量
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
输入source .bash_profile
zsh compinit: insecure directories, run compaudit for list.\
Ignore insecure directories and continue [y] or abort compinit [n]?
-
验证配置是否成功nvm
这里有个问题就是自己在 ~/.bash_profile 中配置环境变量, 可是每次重启终端后配置的不生效.需要重新执行 : $source ~/.bash_profile
发现zsh加载的是 ~/.zshrc文件,而 ‘.zshrc’ 文件中并没有定义任务环境变量。
解决办法
在~/.zshrc文件最后,增加一行: source ~/.bash_profile
过程中问题
有时提示打开Mac终端控制台出现:-bash: /Users/xxx/.profile: No such file or directory , 发现.zshrc中也有环境变量配置,所以就把.bash_profile删了,再把在~/.zshrc文件最后,删除一行: source ~/.bash_profile