Download, install and use nvm

1. The role of nvm

nvm is a tool that facilitates switching between different NodeJS versions, because in actual work, you may not only write one project at a time. There may be old projects that need to be maintained or other situations. Different projects rely on different versions of NodeJS. If it is too troublesome to constantly uninstall and install different versions, using nvm is very convenient.

2. Download and installation of nvm

Download address: Releases · coreybutler/nvm-windows · GitHub

 

Installation ===> Just double-click the exe suffix file after decompression, and then click Next to install it. However, there is one thing to note here. If Node is already installed on the computer, it is recommended to delete it first, and then check the environment variables and path. Whether to delete it? When I installed it for the first time, I did not delete the Node on the computer itself. As a result, the nvm switch to Node never took effect. Even though I switched the version, I still got an error saying that the npm version I used was wrong. At first, I thought it was me who installed Node. The npm version was not updated together when 

After the installation is complete, enter nvm -v to view the nvm version.

Then there are some related configurations that need to be operated. First, enter the installation path of nvm and add two lines of code to the setting.txt file (configuring the mirror will make subsequent downloads faster)

Environment variables also need to be configured. Both user variables and system variables need to be configured according to the path of nvm (by default, nvm automatically configures environment variables after installation)

 

 After everything is completed, you can try to operate Node with the following commands

nvm off                     // 禁用node.js版本管理
nvm on                      // 启用node.js版本管理
nvm install <version>       // 安装node.js的命名 version是版本号 例如:nvm install 16.8.1
nvm uninstall <version>     // 卸载node.js是的命令,卸载指定版本的nodejs,当安装失败时卸载使用
nvm ls                      // 显示所有安装的node.js版本,当前使用的版本前会带*号
nvm list available          // 显示可以安装的所有node.js的版本
nvm use <version>           // 切换到使用指定的nodejs版本
nvm v                       // 显示nvm版本
nvm install stable          // 安装最新稳定版

Guess you like

Origin blog.csdn.net/Javahtml12/article/details/131599985