Installation and use of nvm (details)

What is nvm?
Nvm is also called node.js version management in English. It is a nodejs version management tool. Both nvm and npm are node.js version management tools. In order to solve the incompatibility of various versions of node.js, you can use it to install and switch different versions of node.js.

nvm download
You can click here to download the latest version on github, this download installs the windows version. Open the URL and we can see that there are two versions:

nvm 1.1.7-setup.zip: installation version, it is recommended to use
nvm 1.1.7-noinstall.zip: green free installation version, but it needs to be configured when using it.
nvm installation
1. Install nvm after uninstalling the previous node, nvm-setup.exe installation version, run nvm-setup.exe directly

2. Select the nvm installation path

3. Select the nodejs path

4. Confirm the installation

After installation, the system variables are automatically set, no need to manually change

5. Confirm after installation

Open CMD, enter the command  nvm , and the installation is successful, as shown below. You can see that various commands are listed in it, and the Chinese instructions of these commands will be listed at the end of this section.

Nvm common commands:

nvm install node: Install the latest version of node.js. nvm i == nvm install.


nvm install [version]: Install the specified version of node.js.
nvm use [version]: Use a certain version of node.
If you have installed node before, the nvm use command will fail here (the prompt is successful, but the actual switch has not been made). This time, the NVM_SYMLINK configuration automatically generated in the environment variable is incorrect. The solution:

    

 

  Successfully resolved.

nvm list: List which versions of node are currently installed.
nvm uninstall [version]: Uninstall the specified version of node.
nvm node_mirror [url]: Set the mirror of nvm.
nvm npm_mirror [url]: Set the mirror of npm.

3. Operate on the cmd console

nvm query version number

Query the version of node that can be downloaded

nvm list available  

Install the specified version

nvm install xxx   

Normally, node and npm will be bundled and downloaded. If npm is not downloaded, try to reverse the order of the environment variables NVM_HOME and NVM_SYMLINK.

Check the installed node version

nvm list

Switch the node version (if it fails, open cmd as an administrator to switch)

nvm use xxx

5. After finding the specified nvm to open:

        

 Add these two lines to the file:

        node_mirror: https://npm.taobao.org/mirrors/node/

        npm_mirror: https://npm.taobao.org/mirrors/npm/

Environment variable configuration:

    

Check whether the environment variable is configured:

Consistent with the following configuration: 

User Environment:
 System Variables:                 


test:

nvm -v View current version
nvm --config 
nvm list View installed node version list
nvm install version number download corresponding node version
nvm use version number switch node version
nvm on open nvm
nvm off close nvm

If installed to the D drive, you need to configure the corresponding environment, as shown in the figure: (enter the corresponding file location)

                 

 (2) configuration

        Find the location of the nvm file and click on the setting

Then enter the following code after it: (this is the configuration mirror source)

node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
 3. Use
1. Uninstall the previous node.js

2. Open cmd at the location of the nvm file just now

3. Enter the following code to view the node version that nvm can install

nvm ls // View all installed node.js versions
 
nvm list available // Check and display all node.js versions that can be installed
4. The version corresponding to the installation.

nvm install version number // For example: nvm install 14.19.0
5. Switch to the installed version

nvm use version number // Switch to use the specified nodejs version
6. Check whether the switch is complete, and open a new cmd

node -v
Four, some commands of nvm
nvm command line operation command
1, nvm nvm list is to find all node versions on this computer
 
- nvm list to view the installed version
- nvm list installed to view the installed version
- nvm list available to view Version 2 that can be installed on the network
 
, nvm install installs the latest version nvm
 
3, nvm use <version> ## switch to use the specified version node
 
4, nvm ls lists all versions
 
5, nvm current displays the current version
 
6, nvm alias <name> <version> ## Add aliases to different version numbers
 
7, nvm unalias <name> ## Delete defined aliases
 
8, nvm reinstall-packages <version> ## In the current version node environment, reinstall the specified version number globally npm package
 
9, nvm on open nodejs control
 
10, nvm off close nodejs control
 
11, nvm proxy view settings and proxy
 
12, nvm node_mirror [url] set or view node_mirror in setting.txt, if not set, the default is https: //nodejs.org/dist/
  nvm npm_mirror [url] Set or view npm_mirror in setting.txt, if not set, the default is: https://github.com/npm/npm/archive/.
 
13, nvm uninstall <version> Uninstall the specified version
 
14 ,nvm use [version] [arch] Switch the specified node version and number of digits
 
15,nvm root [path] Set and view the root path
 
16,nvm version View the current version

nvm arch: Shows whether node is running on 32-bit or 64-bit.
nvm install <version> [arch] : Install node, version is a specific version or the latest stable version latest. The optional parameter arch specifies whether to install the 32-bit or 64-bit version, and the default is the system bit. --insecure can be added to bypass SSL for remote servers.
nvm list [available] : Show the list of installed ones. The optional parameter available displays all versions that can be installed. list can be simplified to ls.
nvm on : Enable node.js version management.
nvm off : Turn off node.js version management.
nvm proxy [url] : Set download proxy. Without the optional parameter url, the current proxy is displayed. Setting url to none removes the proxy.
nvm node_mirror [url] : Set node mirror. The default is https://nodejs.org/dist/. If no url is specified, the default url will be used. After setting, you can go to the settings.txt file in the installation directory to view it, or you can directly operate in this file.
nvm npm_mirror [url] : Set npm mirror. https://github.com/npm/cli/archive/. If no url is specified, the default url will be used. After setting, you can go to the settings.txt file in the installation directory to view it, or you can directly operate in this file.
nvm uninstall <version> : Uninstall the specified version node.
nvm use [version] [arch] : Use the specified version node. 32/64 bits can be specified.
nvm root [path] : Set the directory where different versions of node are stored. If not set, the current directory is used by default.
nvm version : Displays the nvm version. version can be simplified to v.

Guess you like

Origin blog.csdn.net/weixin_46016659/article/details/129814499