Use nvm (node.js version management) to install and manage nodejs

In view of the current articles on the Internet about the operation steps of NVM installation NodeJS, everyone is learning from each other, and few original articles are seen, and many operation steps are redundant and outdated. Therefore, based on the actual front-end project development experience, I have reorganized the installation steps of the latest NVM+NodeJS for future reference.
 

Table of contents

1. Introduction to nvm

2.nvm download (windows)

3. Installation (the version installed this time is 1.1.17)

4. Some common commands of nvm


1. Introduction to nvm

NVM: Node Version Manage, which is the version management tool of Node. Using NVM, it is very convenient to switch between multiple NodeJS versions.

During project development, different projects may depend on different versions of NodeJS. In this case, switching NodeJS versions will be very troublesome. Therefore, it is particularly important to use NVM to manage NodeJS versions.

2.nvm download (windows)

github download address  This version is the windows version. Open the URL and scroll down to see the information of each version. You can choose the corresponding version according to your needs. Here, it is recommended that you download nvm-setup.zip, which is more convenient.

3. Installation (the version installed this time is 1.1.17)

After downloading the nvm-setup.zip compressed package, unzip it to the path you need and double-click the nvm-setup.exe unzip file

 Then select the path you need to install. The default installation path here is: C:\Users\xxx\AppData\Roaming\npm

Notice! ! ! In order to avoid unnecessary trouble, it is best not to have spaces and Chinese characters in the installation path

Notice! ! ! In order to avoid unnecessary trouble, it is best not to have spaces and Chinese characters in the installation path

Notice! ! ! In order to avoid unnecessary trouble, it is best not to have spaces and Chinese characters in the installation path

Say important things three times! ! !

Then choose your nodejs installation path. The default installation path here is: C:\Program Files\nodejs

 Finally install to confirm the installation

After the installation is complete, open cmd and enter nvm. If the installation is successful, it will display

 Check npm and nodejs version

If node -v and npm -v report errors, you can manually configure the environment variables

Find the path of nodejs and copy it down (note that the node.exe file here may be named node64.exe, just change it to node.exe)

Then add the path you just copied in user variables

Finally, set the setting.exe file in the nvm folder

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

Open cmd again and try node -v and npm -v

4. The following are some common commands of nvm

  • nvm arch [32|64]: Shows whether the node is running in 32-bit or 64-bit mode. Specify 32 or 64 to override the default architecture.
  • nvm install <version> [arch]: The version can be the node.js version, or the "latest" version of the latest stable release. (Optional) Specifies whether to install the 32-bit or 64-bit version (defaults to system architecture). Set [arch]to "All" to install both 32 and 64 bit versions.
  • nvm list [available]: List node.js installations. availableType at the end to display a list of versions available for download.
  • nvm on: Enable node.js version management.
  • nvm off: disables node.js version management (does not uninstall anything).
  • nvm proxy [url]: Sets the proxy for downloading. Leave [url]blank to see the current proxies. Set [url]to 'none' to remove the proxy.
  • nvm uninstall <version>: Uninstall a specific version.
  • nvm use <version> [arch]: Switch to using the specified version. (Optional) Specify 32/64 bit architecture. nvm use <arch>will continue to use the selected version, but switch to 32/64 bit mode depending on the value provided <arch>.
  • nvm root <path>: Sets the directory where nvm should store different versions of node.js. If <path>not set, the current root directory will be displayed.
  • nvm version: Display the current running version of NVM for Windows.

nvm list available: View the NodeJS version that can be installed online

nvm ls: List all NodeJS versions installed in NVM.

nvm current: Displays the Node version currently in use.

nvm install xx.xx.xx: Install the specified version of NodeJS online in NVM, where xx.xx.xx is the specified version number.

nvm uninstall xx.xx.xx: Uninstall the specified version of NodeJS in NVM, where xx.xx.xx is the specified version number.

nvm use xx.xx.xx: switch NodeJS version, xx.xx.xx is the specified version number.

nvm version: Displays the version number of the NVM currently in use.

Other commands, such as nvm arch, nvm on, nvm off, nvm proxy, nvm node_mirror, nvm npm_mirror, nvm root, etc., are not introduced here due to limited space.

Guess you like

Origin blog.csdn.net/qq_44848480/article/details/130357113