We may be doing it at the same time 2 One or more projects , And different projects use node The version may be different , Or use the latest node Version for testing and learning . under these circumstances , For maintaining multiple versions of node It will be a very troublesome thing , and nvm It is to solve this problem that , It is convenient to carry out multiple node Switch between versions , And this is just nvm The value of , Details can be found in nvm Official website view .
1.nvm What is it? ？
nvm full name node.js version management, As the name suggests, it's a nodejs Version management tools . It allows you to install and switch different versions of nodejs. Here's a list of downloads 、 Installation and usage .
2. download nvm
Open the website and we can see that there are two versions ：
nvm-noinstall.zip： Green installation free version , But you need to configure it when you use it .
nvm-setup.zip： Installed version , Recommended
3. install nvm
Here we use the installation version , After installation, it can be used directly , No need to manually configure environment variables .
Double click download okay nvm-setup.exe
choice nvm The installation path （ If C Not enough disk space , You can switch paths , But you must not travel in Chinese ）
choice node route （ This path is after you install node Path to version ）
installation is complete , You can use ,
open CMD, Enter the command nvm , If the installation is successful, it will be shown as follows . You can see that it lists all kinds of commands .
4. Management and installation node edition
1、 View all locally installed versions ; There are optional parameters available, Show all downloadable versions .
nvm list [available]
2、 install , The version number in the command can be customized
nvm install 11.13.0
3、 Use a specific version
nvm use 11.13.0
4、 Uninstall the specified version node
nvm uninstall 11.13.0
5.nvm Common commands
1. Show node Is running on the 32 A still 64 position .
2. install node, version It can be a specific version or the latest stable version latest. Optional parameters arch Specify installation 32 A still 64 Bit version , The default is the number of system digits . You can add --insecure Bypass remote servers SSL.
nvm install <version> [arch]
3. A list of installed . Optional parameters available, Show all installable versions .list Can be simplified as ls.
nvm list [available]
4. Turn on node.js version management .
5. close node.js version management .
6. Set up download agent . No optional parameters url, Show current agent . take url Set to none The agent is removed .
nvm proxy [url]
7. Set up node Mirror image . The default is https://nodejs.org/dist/. If you don't write url, Use default url. After setting, you can go to the installation directory settings.txt The file to view , You can also operate directly in the file .
nvm node_mirror [url]
8. Set up npm Mirror image .https://github.com/npm/cli/ar.... If you don't write url, Use default url. After setting, you can go to the installation directory settings.txt The file to view , You can also operate directly in the file .
nvm npm_mirror [url]
9. Uninstall the specified version node.
nvm uninstall <version>
10. Use developed version node. Can be specified 32/64 position .
nvm use [version] [arch]
11. Set to store different versions node The catalog of . If not set , The current directory is used by default .
nvm root [path]
12. Show nvm edition .version Can be simplified as v.