参考官方文档
其中官方文档提供了两条命令,选择其中一条即可,前提是你有安装wget或curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
你以为这就完了?如果安装不成功会提示,但是wget没提示,建议用curl来下载。由于某些原因,raw.githubusercontent.com的域名解析被污染了
解决方法:修改/etc/hosts文件 其中该域名的域名解析IP地址需要参考网站https://www.ipaddress.com/reverse-ip-lookup
官方文档也说了,会向这些目录(~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc)添加一段export环境命令
根据你linux环境变量使用source命令,由于本人的linux是kali,只能用~/.zshrc,其他的linux大部分用~/.profile应该是可以的
source ~/.zshrc
然后这里应该就能使用了,在命令行输入nvm -v试试看,如果没问题就会出现版本号
nvm -v