NVM的安装

620 阅读1分钟

使用命令安装

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

或者

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

添加到环境变量,修改随便一个文件

~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc,

.zshrc为例子,运行
vim ~/.zshrc
添加
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

运行 source ~/.zshrc

nvm 安装失败,有时候会报错Failed to connect to raw.githubusercontent.com port 443: Connection refused,可以通过修改DNS的方式修复 输入 sudo vim /etc/resolv.conf
修改为 nameserver 114.114.114.114
或者 nameserver 8.8.8.8
然后再尝试上面步骤 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash