查看当前源
┌─[root@DESKTOP-LATEX] - [~] - [327]
└─[$] npm config list [23:29:25]
; cli configs
metrics-registry = "http://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.14.6 node/v12.18.4 linux x64"
; userconfig /root/.npmrc
registry = "http://registry.npm.taobao.org/"
方式1. 临时换源
npm install express --registry https://registry.npm.taobao.org
方式2. 更换淘宝镜像
npm config set registry https://registry.npm.taobao.org
方式3. 使用cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
方式4. 使用nrm
nrm 是一个 NPM 源管理器,允许你快速地在如下 NPM 源间切换
- npm
- cnpm
- strongloop
- european
- australia
- nodejitsu
- taobao
nrm安装
npm install -g nrm --registry=https://registry.npm.taobao.org
列出可用源
nrm ls
查看当前源
npm current
切换源
nrm use <registry>