VUE development artifact-NVM nodejs version control tool nvm

Preface

When learning front-end frameworks or nodejs, sometimes some frameworks have requirements for the nodejs version. But at this time, the 10.x version of nodejs is already installed on your computer. You don't want to update directly to 12.x. You want to save the 10.x and 12.x versions at the same time, and you can switch the nodejs version at any time when necessary. Then nvm tool is worth having.

1. First install nvm


Download address: Releases · coreybutler/nvm-windows (github.com)
Alternate download address

1. Select the appropriate installation package to download and install.

Insert image description here
Bloggers still prefer to install .exe, so it is not bad to manually select the installation path during the installation process.
You can choose which type of installation package to download.
After downloading, click the .exe file to install.

 Insert image description here

 Note here: It is best not to have spaces or Chinese characters in the nvm installation path, otherwise problems may occur!

Insert image description here

Insert image description here

2. Configure the Taobao mirror when downloading the nodejs package, which will be faster.

root: D:\nvm-nodejs\nvm     # 这是我安装nvm的目录
path: C:\Program Files\nodejs   # 这是nvm控制当前nodejs版本包的目录
arch: 64
proxy: none
node_mirror: http://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

 在安装nvm的目录下找到 settings.txt文件,写入红框中的内容。

Insert image description here

 Insert image description here

 2. Use nvm

1. Check the nvm version (the version number displayed means the installation is successful):nvm v

2. View the list of node versions controllable by nvm: nvm list / nvm ls

3. Go to the official website to check whether the nodejs version you want to install exists. Check the official website for whatever version you need to install.

Insert image description here

 Previous versions | Node.js (nodejs.org)

4. Use nvm to install the nodejs version:nvm install nodejs版本号

5. After installing the required nodejs version, you can switch to any nodejs version.

Use nvm use version number to switch the nodejs version

Precautions

What if the nvm use command does not take effect?
Execute nvm ls after nvm use. Under normal circumstances, there will be an * mark before the currently used version.
But if there is no * in front of all versions after nvm use, or the * has not changed to the version of nvm use, then there is a problem! !
After reviewing the operation, I finally discovered the problem. The default installation directory of nodejs did not have the corresponding node version installed at all.
Solution:
According to the above installation process, you should delete the nodejs directory in the C:\Program Files\nodejs directory, and then re-execute nvm use the currently existing nodejs version. At this time, you will find that the nodejs directory is automatically generated in the C:\Program Files directory. And using nvm ls, I found that the * sign in front of the nodejs version was also marked normally. The corresponding node version has also been generated.
Before deleting the node version currently in use, be sure to switch (nvm use xxx) to this version before deleting it.

Guess you like

Origin blog.csdn.net/wangguoqing_it/article/details/131877085