[nvm] Node Version Manager (NVM) installation, configuration and use (WIN version)

NVM

Package management tools

Install

⭐Note: If you have downloaded node before installation, you must delete the original node!

  1. VisitNVM-Windows’s GitHub page:
  2. Click nvm-setup.exe.

Insert image description here

  1. Follow the prompts to the next step and select a custom location for the file location.

  2. Verify that the installation was successful nvm version . If successful, it will display the version number of NVM.

    Insert image description here

use

  1. nvm list available View all versions that can be downloaded

Insert image description here

  1. nvm install 18.18.0 download the version to use
  2. nvm use 18.18.0 uses this node version

Configuration

  1. Set node_globel, node_cache configuration

    # 全局安装路径
    npm config set prefix  "路径"
    # 全局缓存路径
    npm config set cache "路径"
    # 配置完后请确认配置成功
    npm config ls
    
  2. Open computer environment configuration-environment variables

    • The path in the user variable, and finally add the path to node_globel just set

Insert image description here

Insert image description here

  1. npm replaces domestic mirror source

    // 查询源
    npm config get registry
    
    // 更换国内源
    npm config set registry https://registry.npmmirror.com
    

Common commands

  1. nvm off // Disable node.js version management (do not uninstall anything)
  2. nvm on // Enable node.js version management
  3. nvm install // The naming of installing node.js version is the version number. For example:nvm install 8.12.0
  4. nvm uninstall // Uninstall node.js is a command to uninstall the specified version of nodejs. Use it when the installation fails.
  5. nvm ls // Display all installed node.js versions
  6. nvm list available // Display all node.js versions that can be installed
  7. nvm use // Switch to use the specified nodejs version
  8. nvm v // Display nvm version
  9. nvm install stable // Install the latest stable version

nvm command line operation command

  1. nvm list is to find all node versions on this computer
    • nvm list View installed versions
    • nvm list installed View installed versions
    • nvm list available View the versions that can be installed on the network
  2. nvm install installs the latest version of nvm
  3. nvm use ## Switch to use the specified version node
  4. nvm ls lists all versions
  5. nvm current displays the current version
  6. nvm alias ## Add aliases to different version numbers
  7. nvm unalias ## Delete a defined alias
  8. nvm reinstall-packages ## In the current version of node environment, reinstall the npm package with the specified version number globally.
  9. nvm on opens nodejs control
  10. nvm off turns off nodejs control
  11. nvm proxy View settings and proxy
  12. nvm node_mirror [url] Set or view node_mirror in setting.txt. If not set, the default is https://nodejs.org/dist/
      nvm npm_mirror [url] Set or view npm_mirror in setting.txt. If not set, the default is: https://github.com/npm/npm/archive/.
  13. nvm uninstall uninstalls the specified version
  14. nvm use [version] [arch] switches the specified node version and number of bits
  15. nvm root [path] Set and view the root path
  16. nvm version View the current version

Guess you like

Origin blog.csdn.net/qq_41675812/article/details/133674033