This article mainly introduces how to install nvm under the Linux operating system. If you want to know how to use nvm under the windows operating system, please refer to the article How to manage multiple nodejs versions through nvm_nvm View all node versions-CSDN blog .
1. nvm download
The full name of nvm is Node Version Manager, which is Node version manager. Visit the official website address, check the version you need and download Tags · nvm-sh/nvm · GitHub .
2. Installation
Copy the downloaded file to the folder specified by the Linux system, and then execute the following command to decompress it.
mkdir -p /.nvm
tar -zxvf nvm-0.39.5.tar.gz -C /.nvm
3. Environment configuration
Execute the following command to open the configuration file.
vim ~/.bashrc
At the end of ~/.bashrc, add the following statement:
export NVM_DIR="/.nvm/nvm-0.39.5"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Enable configuration:
source ~/.bashrc
4. Test verification
Execute the following command to check the version number of nvm. If it can be displayed normally, the configuration is successful. Then it prompts that the nvm command cannot be recognized. Please ensure that the NVM_DIR="/.nvm/nvm-0.39.5 configuration file path is correct, and confirm that the nvm.sh file under the file path has execution permission. If not, please execute chmod -x nvm. The sh command adds execution permissions.
nvm -v