Home >Web Front-end >JS Tutorial >How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

青灯夜游
青灯夜游forward
2022-01-12 18:50:154145browse

How to install

node version management tool (nvm) under windows? The following article will introduce you to some pitfalls when installing nvm tools, as well as solutions. I hope it will be helpful to you!

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

Things usually start with the need to maintain old projects and new projects on the local computer, but the old project may need to compare to an older version of node, so if you can at any time Just switch the node version! nvm came into being.

Because I am more cautious, I looked for some pitfalls that others have encountered before installing nvm, and there are still some pitfalls. When I felt that everything was ready (after reading several installation pitfalls articles), I started to operate:

Operating system: win10-64bit, nvm under windows is nvm-windows

Step 1 (very important):

If nodejs has never been installed on this machine, you can skip it This step

Completely (must be completely) uninstall the local node and delete the npm related directory (refer to the solution on stackoverflow)

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

A little translation (my operation) is:

  • To kill the node-related process, you can right-click the menu bar to open the task manager, find the node process and then "End Task"

  • Uninstall node in the application management interface

  • Remove the relevant folders in step 4 above (if they exist)

  • Delete environment variables related to node and npm

  • Run in cmdwhere node You can see whether node has been uninstalled (if it has not been uninstalled, you will see to an installation path)

Step 2:

Official website address: https://github.com/coreybutler /nvm-windows/releases/tag/1.1.8

Click to download the installation package. I installed 1.1.8. Just find the installation package in the release interface and download it

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

Step 3:

Install nvm-setup, which is the installation method of ordinary software. The address does not need to be changed ( I chose the following address). After installation, two environment variables will be added automatically

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

Open the nvm installation directory. The default should be: C:\Users{user}\ AppData\Roaming\nvm\

Modify the settings.txt file and change the npm image to the Taobao image. This is my configuration. The default root and path do not need to be changed. Add the following Two lines

root: C:\Users\PARATERA\AppData\Roaming\nvm
path: C:\Users\PARATERA\AppData\Roaming\nodejs

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

Step 4:

You can execute the following command to operate

nvm -v: Check whether nvm is installed successfully

nvm arch: Display whether the node is running in 32-bit or 64-bit mode

nvm install [version number]: Install the corresponding version of node, such as nvm install v16.5.0 After installation, you will see that the nvm directory will have additional folders for the corresponding version. To install the latest version, use the command nvm install latest

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

##nvm ls<em></em>: List installed node.js versions

nvm use [version number]<em></em>: Use the installed node16.5.0 version. There is no global variable node or npm before the version is specified successfully. There is no need to try it

After successful version switching

  • node -v<em></em>: View the current node version

  • npm -v<em></em>: View the current npm version

Pitfalls:

Error when running nvm use [version number]:

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

##Solution: Open cmd with administrator rights and re-operate

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

##See How to install the node version management tool (nvm) under windows and how to avoid pitfalls?Now using node vXXXX

and you are done, you can use

node -vCheck whether the switched version is as expected

You can have fun playing! How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

but! Use

npm i -g [package] under a certain version. The installed global package can only be used under the corresponding version. <em></em>For example:

How to install the node version management tool (nvm) under windows and how to avoid pitfalls?

For more node-related knowledge, please visit: nodejs tutorial! !

The above is the detailed content of How to install the node version management tool (nvm) under windows and how to avoid pitfalls?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.cn. If there is any infringement, please contact admin@php.cn delete