Article directory
01 nvm introduction
nvm, node version manager, is a tool that facilitates switching and managing node.js versions.
Things to note before installing nvm:
- Uninstall the existing node.js
- Avoid spaces and Chinese characters in all installation directories
- Choose to run cmd terminal as administrator to execute nvm command
02 Installation
Go to the GitHub project homepage to download the installation package.
https://github.com/coreybutler/nvm-windows/releases
After downloading, unzip it. There is a nvm-setup.exe
file inside. Double-click to run it. Be careful not to have spaces or Chinese characters in the directory.
03 Set up mirroring
Open the cmd console as an administrator and enter the command to set up the mirror:
# 设置nodejs镜像
nvm node_mirror http://npm.taobao.org/mirrors/node/
# 设置npm镜像
nvm npm_mirror https://npm.taobao.org/mirrors/npm/
04 Installation and version management
# 查看可安装的版本
nvm list available
# 查看已安装的版本
nvm list
# 安装某一版本(推荐LTS版本)
nvm install 18.16.1
# 切换至某一版本
nvm use 18.16.1
# 卸载某一版本
nvm uninstall 18.16.1
05 Basic usage
Continue to enter the command in the cmd console:
# 查看node版本
node -v
# 查看npm版本
npm -v
# 查看npm镜像
npm get registry
# 设置为国内镜像
npm config set registry https://registry.npm.taobao.org/
# 安装express框架 并将其保存为开发依赖
npm install express --save-dev