NVM, a version management tool for nodejs
NVM is a git based nodejs version management tool, similar to RVM in Ruby or Jenv in Java. It can easily perform operations such as switching, installing, and uninstalling Node.js versions.
Before starting to use NVM, we need to install NVM on the system. In Linux, the curl command can be used for installation, as follows:
Curl - o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh |Bash
In Windows, you can access the official website of NVM（ https://github.com/coreybutler/nvm-windows/releases ）Download the nvm setup.zip file for installation.
After installing NVM, we can take a look at how to use it.
List available nodejs versions: nvm ls remote
Install the specified version of nodejs: nvm install 8.0.0
Use the specified version of nodejs: nvm use 8.0.0
Uninstall the specified version of nodejs: nvm uninstall 8.0.0
Set nodejs default version: nvm alias default 6.0.0
It should be noted that for Windows systems, by default, NVM does not automatically add nodejs to the system environment variable and needs to be manually added. Add can be found in the installation directory of NVM_ To_ Path.cmd and rm_ From_ Two files, path.cmd, can be used to add or remove the path of node.js by executing these scripts.
Managing nodejs versions through NVM is very convenient and can also avoid conflicts caused by multiple projects requiring different versions of nodejs.
Manually switch nodejs version
The above introduces the use of NVM, but in some cases, we may not want to use NVM for version switching and instead want to manually switch the nodejs version. So how should we proceed with this operation?
Firstly, you need to download the required version of the nodejs installation package and extract it to the specified directory.
Then, we can manually switch by setting system environment variables. In Linux, the bin directory of nodejs can be added to $PATH, such as:
In Windows, it is necessary to manually add the path of nodejs to the system environment variable.
When switching the nodejs version, simply execute the commands set above in the terminal.
Copyright Description：No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。