What is NVM?

Different applications require different versions of Node.js, and switching and installing new versions of Node.js can be annoying and cause confusing problems. NVM is designed to solve node.js installation and versioning problems.


2. Install the NVM

Git install > Git install > Git install > Git install How to install Git: here!

1. Installation steps
Git clone https://github.com/nvm-sh/nvm.git. NVM CD ~/. NVM git checkout v0.38.0Copy the code

2. Configure the global environment
The nano. Following (write code below) * * * * * * * * * * * * export NVM_DIR = ". $HOME/NVM "[-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 * * * * * * * * * * * *Copy the code

[Note] : If the previous configuration fails, try creating a file: ~/. Profile or ~/. ZSHRC. The operation is the same.


3. Update system environment variables

The environment variables configured above are updated with the following command:

source ~/.bash_profile
Copy the code

4. Common NVM commands
NVM install <version> Install the specified version, For example, NVM install v8.14.0 NVM uninstall <version> Uninstalls the specified version. NVM ls Lists all installed versions. NVM use <version> Switch to using the specified version NVM current NVM alias Default <version> Set the default node version. NVM deactivate Unbind the current node version. By default, you cannot delete a node whose version is default. Especially if only one Node is installed, unbind the current version and then use NVM uninstall <version> to delete itCopy the code

Install Node.js
#1. Install Node.jsNVM install 14.17.5
#2. View the Node.js version
node -v 

#3. Switch the Node.js versionNVM ls (view all installed Node.js versions) NVM use < version number > (select the Node.js version number listed above)Copy the code

443 error
1. Explanation of reasons

A 443 error is generated because some links cannot be accessed:

#1. Install commandsThe curl - o - https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
#2. Error message:
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443 
Copy the code
2. Solutions

Install NVM using Git install on this page.


5. Reference documents
  • Node.js installation and environment configuration!