Article Directory
Node version switching in windows:
Application Scenario
At work, we may be developing two or more different projects at the same time. Each project has different requirements, and different projects must rely on different versions of the NodeJS operating environment. In this case, it will be a very troublesome thing to maintain multiple versions of node. nvm was created to solve this problem. It can easily switch between multiple node versions on the same device.
Different versions can be installed at the same time without uninstalling the existing version
The specific operation is as follows:
install nvm
nvm download address nvm download address
Refer to other people's installation
nvm common commands
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 // 安装最新稳定版
Execute the nvm command to view the version of node that can be installed
nvm list available
Check the version of node installed locally
nvm list
Install the specified node version
Nvm install v is followed by the version number
nvm install v14.18.0
Switch to the specified node version
nvm use v16.14.0
//有时候是,不用写v
nvm install 14.18.0
Note: Sometimes an error will be reported. At this time, you need to run the cmd command as an administrator
and enter nvm use in this directory...
Note:
The cnpm and yarn in the newly installed version and the previous version may not be common, and sometimes it needs to be re-installed globally
Yarn and cnpm installation tutorial
yarn:
npm install -g yarn
yarn --version
cnpm:
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm -v
pnpm:
npm install -g pnpm
Domestic npm source mirror (npm accelerated download)
Specify npm mirror
The official original mirror URL of npm is: https://registry.npmjs.org/Taobao NPM mirror: https://registry.npm.taobao.org
Aliyun NPM mirror: https://npm.aliyun.com Tencent Cloud
NPM mirror: https://mirrors.cloud.tencent.com/npm/Huawei Cloud NPM mirror: https://mirrors.huaweicloud.com/repository/npm/Netease NPM mirror: https://mirrors.huaweicloud.com/repository/npm/NetEase NPM mirror: https ://mirrors.163.com/npm/University of Chinese Academy of Sciences open-source mirror station: http://mirrors.ustc.edu.cn/Tsinghua University open-source mirror station : https://mirrors.tuna.tsinghua.edu.cn/Tencent , Huawei, Ali’s mirror stations are basically complete
Use Taobao mirror source to speed up NPM
npm config set registry https://registry.npm.taobao.org
Use Alibaba Cloud mirror source to speed up NPM
npm config set registry https://npm.aliyun.com
Accelerate NPM using Tencent Cloud image source
npm config set registry http://mirrors.cloud.tencent.com/npm/
Use HUAWEI CLOUD image sources to speed up NPM
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
To use that mirror, you only need npm config set registry + the corresponding mirror URL
npm config set registry
View the current mirror source : npm config get registry
npm config get registry
It is recommended to use the above method to specify the npm image. Of course, the method is not unique. You can also use nrm to specify the npm image.
what is nrm
nrm is an npm source manager that allows you to quickly switch between npm sources.
install nrm
npm install -g nrm
use
View optional source
nrm ls
to switch
If you want to switch to taobao source, execute the command
nrm use taobao
test speed
nrm test