最近在新的电脑上安装nvm,遇到了一些问题,这里就把步骤和问题一一罗列一下。
1 通过brew安装nvm
|
1
|
`brew install nvm`
|
问题一:直接跳出链接某个地址失败。
解决方法:重启mac,再重新执行安装命令。
问题二 :停在updating brew ,然后就没有下文了。
原因:国外的源连不上,换成国内的就好。
解决:
|
1
2
3
4
5
6
7
|
`#替换brew.git:`
`cd` `"$(brew --repo)"`
`git remote` `set``-url origin https:``//mirrors.ustc.edu.cn/brew.git`
`#替换homebrew-core.git:`
`cd` `"$(brew --repo)/Library/Taps/homebrew/homebrew-core"`
`git remote` `set``-url origin https:``//mirrors.ustc.edu.cn/homebrew-core.git`
|
安装完毕后可以选择再把源替换回来。
|
1
2
3
4
5
6
7
|
`#重置brew.git:`
`cd` `"$(brew --repo)"`
`git remote` `set``-url origin https:``//github.com/Homebrew/brew.git`
`#重置homebrew-core.git:`
`cd` `"$(brew --repo)/Library/Taps/homebrew/homebrew-core"`
`git remote` `set``-url origin https:``//github.com/Homebrew/homebrew-core.git`
|
2 配置环境变量
1 创建nvm的工作目录
|
1
|
`mkdir ~/.nvm`
|
2 新建.bash_profile文件
|
1
|
`touch ~/.bash_profile`
|
3 打开.bash_profile文件
|
1
|
`open -e ~/.bash_profile`
|
添加以下内容
|
1
2
|
`export NVM_DIR=``"$HOME/.nvm"`
`.` `"/usr/local/opt/nvm/nvm.sh"`
|
4 执行文件
|
1
|
`source ~/.bash_profile`
|
最后执行命令nvm,就可以看到安装成功了。