NodeJS version management tool—NVM

1. Introduction to nvm

nvm (Node Version Manager) is a node version management tool that can quickly install, switch, uninstall, view, etc. node versions. It can easily switch different versions of Node.js that it relies on according to different needs during project development, allowing developers to switch between different environments to better ensure the stable operation of the software.

2. nvm installation

Notice: Before installing nvm, you need to delete the previously installed node.

  1. Official download: https://github.com/coreybutler/nvm-windows/releases
    Insert image description here

  2. installation steps

Insert image description here

Insert image description here
Insert image description here
Insert image description here

  1. Directory file configuration
    Open this directory and add:
    node_mirror: https://npm.taobao.org/mirrors/node/
    npm_mirror: https://npm.taobao.org/mirrors/npm/
    Insert image description here
    Add the following content:
    Insert image description here

  2. Environment variable configuration:
    Right-click My Computer-Properties-Advanced System Settings-Environment Variables-Check whether the path is the same as the directory
    Insert image description here
    Insert image description here
    Insert image description here

  3. After installation, check the version
    and right-click to start
    Insert image description here
    nvm -v
    Insert image description here

3. nvm usage (instructions)

nvm off                     // 禁用node.js版本管理(不卸载任何东西)
nvm on                      // 启用node.js版本管理
nvm install <version>       // 安装node.js的命名 version是版本号 例如:nvm install 8.12.0
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          // 安装最新稳定版
  1. nvm ls checks the installable node versions, only showing part of them
    Insert image description here

  2. nvm install <version number> Install the specified version and nvm ls to view the node version to be installed
    Insert image description here

  3. nvm use <version number> switch node version
    Insert image description here

  4. node -v Check whether the node switch is successful
    Insert image description here

  5. npm -v Check whether npm is installed (installed successfully)
    Insert image description here

Note : If all the above problems are solved, if when running the project, it appears that node is not an internal command, you can try to reopen the editor or command box.

Guess you like

Origin blog.csdn.net/weixin_44767973/article/details/131591333