1. Detailed installation steps ( official website reference )
The operation of the above two commands is actually to install and download the nvm script, but here we need to pay attention, we may report a 443 error when we directly access,
we need to modify the proxy file /etc/hosts on our server, and add the following proxy through the vi command
151.101.8.133 raw.githubusercontent.com
Let's execute any of the following commands again. If the download connection times out at this time, try a few more times
// 以下两种方式均可
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
Note that during this process, we can see that after the download is complete, our nvm is downloaded to the
~/.nvm directory by default
Check the ~/.bashrc file to see if the nvm path has been configured.
As shown in the figure:
If the above path configuration appears, it means that it has been configured.
At this time, use the source command to make the configuration take effect
source ~/.bashrc
After executing source, we check whether our nvm can be used normally
// 测试 是否nvm 安装好
nvm -v
If you can see the following output after executing the command 0.39.2 (because we downloaded the 0.39.2 version), it means we have installed it
other instructions
Since nvm is an nvm.sh script, not an instruction, when we want to use nvm instructions in a bash script, we can add nvm.sh to our created bash script file. The code example is as follows, where the source of nvm can be
used directory, or configured in the configuration file, can be
#! /bin/sh
#source ~/.bashrc
nvm -v
nvm ls