nvm download manages different versions of node

Practical steps of how to install nodejs on NVM
There are many ways to install nodejs.

The first one: official website download

Download and install through nodejs official website, but there is a defect that different versions of nodejs cannot be switched smoothly.

The second: NVM installation

NVM can help us quickly switch node versions. However, there are many pitfalls in the process of installing NVM, and many documents found on the Internet did not solve the problem. Here is a summary to help you install the software smoothly.

1. Download the nvm installation package

1 Download address

Download the latest version from github: https://github.com/coreybutler/nvm-windows/releases

It is recommended to download the third package: nvm-setup.zip

2 nvm flags for successful installation

command line: nvm

The following code appears successfully

2. Configure Taobao Mirror

Since nvm's default download address http://nodejs.org/dist/ is a foreign server, the speed is very slow, so you can switch to Taobao's mirror image, and the download speed will be much faster.

Configuration method:

Open the installation path of nvm, the default installation path is: C:\Users\zhong\AppData\Roaming\nvm

Open settings.txt and add the following files

root: C:\Users\zhong\AppData\Roaming\nvm 
path: C:\Program Files\nodejs 
arch: 64 
proxy: none
node_mirror: http://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

3. Install node

1 nvm installation command:
nvm install version
version is the version of nodejs to be installed, which can be found on the official website.
For example:
nvm install v11.6.0
nvm install 11.6.0
2 Key points during installation:

Downloading means that npm is being downloaded. Be sure to wait until the download is complete, otherwise you will find that npm will not be available.

Installation complete means nodejs installation is complete

ps:

If the Taobao mirror is not set in the second step, the download speed will be very slow. Just like I did before, I thought that nodejs was installed, so I hurriedly closed the command line. Finally, I found that npm could not adapt. After searching for a long time, I found out that npm had not finished downloading.

4. Switch nodejs version

1 Query all nodejs versions nvm ls
2 View all nodejs versions currently installed nvm ls
3. Switch nodojs commandsnvm use 版本号

Five, configure environment variables

In order to use the nvm command globally, you need to configure the environment variables.

Here take win10 as an example, win7 is similar

1 Environment variable address: Click My Computer"Properties"Advanced Settings"Environment Variables"Environment Variable Configuration: Click My Computer"Properties"Advanced Settings"Environment Variables"

2 Delete system variables

a. Find the system variables
and delete the nvm variables that come with the system: NVM_HOME and NVM_SYMLINK

b. Open the path: delete the variable automatically added by nvm
Path = %NVM_HOME%;%NVM_SYMLINK%

3 Configure user variables:
NVM_HOME = C:\Users\zhong\AppData\Roaming\nvm
NVM_SYMLINK = C:\Program Files\nodejs
Path = %NVM_HOME%;%NVM_SYMLINK%

6. Test whether node and npm are installed successfully


Execute the node and npm commands in turn, and the following results show that node
npm is successful

At this point, nvm, node, and npm are all installed successfully. Installation failures are often caused by npm not being downloaded successfully, or environment variables not being set successfully, just try a few more times.

Guess you like

Origin blog.csdn.net/qq_38110274/article/details/106157939