nvm 安装及报错
在自己尝试根据官方的方式安装,却始终失败,最终通过大量搜索终于成功安装,在此记录下来。
nvm 官方安装方式
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
报错内容: curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
由于网络原因无法连接,我更改了 host 也没办法
1. 解决办法
直接从github下载nvm仓库到本地,nvm GitHub 地址:https://github.com/nvm-sh/nvm
git clone https://github.com/nvm-sh/nvm.git
或者直接下载zip压缩包解压,这里我是直接在github下载zip压缩包解压。
下载完成之后:
找到 install.sh 文件拖到终端即可 回车运行安装
或者命令:~/nvm/install.sh
2.配置环境
打开终端输入以下代码 ,根据你的终端选择 ~/.bash_profile 这里可能会出现权限问题。
标题执行~/.bash_profile 出现zsh: permission denied:
解决方式:在终端执行一下代码
注意:将其中的yourusername替换成你的用户名
/usr/bin/sudo /bin/chmod u+rwx /Users/yourusername/.bash_profile
/usr/bin/sudo /usr/sbin/chown yourusername /Users/yourusername/.bash_profile
成功后再次运行~/.bash_profile命令,然后输入以下命令
echo "export PATH=$PATH:/usr/local/go/bin" | sudo tee -a /etc/profile
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
3.重启终端完成 nvm 测试环境配置,重置终端代码如下
bash:source ~/.bash_profile
查看安装情况,是否可以正常输出
nvm --version