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.
-
Official download: https://github.com/coreybutler/nvm-windows/releases
-
installation steps
-
Directory file configuration
Open this directory and add:
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
Add the following content:
-
Environment variable configuration:
Right-click My Computer-Properties-Advanced System Settings-Environment Variables-Check whether the path is the same as the directory
-
After installation, check the version
and right-click to start
nvm -v
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 // 安装最新稳定版
-
nvm ls checks the installable node versions, only showing part of them
-
nvm install <version number> Install the specified version and nvm ls to view the node version to be installed
-
nvm use <version number> switch node version
-
node -v Check whether the node switch is successful
-
npm -v Check whether npm is installed (installed successfully)
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.