一、查看npm鏡像源
如果你在使用npm時感覺下載速度過慢,可以嘗試切換npm源爲國內的鏡像源,下面是查看npm鏡像源的方法。
1、使用npm官方提供的命令查看鏡像源:
npm config get registry
命令執行後,會輸出當前npm使用的鏡像源地址,比如:
https://registry.npmjs.org/
2、如果你想要使用淘寶鏡像源,可以使用以下命令進行修改:
npm config set registry https://registry.npm.taobao.org/
3、如果你想要切回使用官方鏡像源,可以使用以下命令:
npm config set registry https://registry.npmjs.org/
二、查看npm指定的源地址
有些時候,我們需要查看npm指定的源地址,下面是具體的操作方法。
1、使用npm命令查看npm指定的源地址:
npm config get registry
命令執行後,輸出結果與查看npm鏡像源的命令相同。
三、npm查看時間
有時候,我們需要查看npm的一些運行時間設置,進行相應的修改或調整。下面是查看npm時間的命令。
1、使用npm命令查看各項時間設置:
npm config ls -l | grep timeout
命令執行後,輸出結果如下:
// ssl相關設置 ssl-client-cert="" ssl-client-key="" ssl-ca="" ssl-cert="" ssl-key="" _exitWhenStdinClosed="false" json=false ; short name = false parseable=false ; user-agent user-agent="npm/{npm-version} node/{node-version} {platform} {arch}" fetch-retries=2 fetch-retry-factor=10 fetch-retry-mintimeout=10000 fetch-retry-maxtimeout=60000 ; timing settings timing="false" cache-max=Infinity cache-min=10 cache-get-misses=0 cache-get-hits=0 cache-put-misses=0 cache-put-hits=0 ; directory layout settings ; TODO: move to some sort of layout manager thingy prefix="/usr/local" bin-links=true ignore-scripts=false ; registry settings registry="https://registry.npmjs.org/" ; CLI output settings {...}
四、npm查看鏡像源
npm可以查看當前可用的鏡像源,幫助我們更好地進行選取和判斷。下面是查看npm鏡像源的命令。
1、使用npm命令查看當前可用的鏡像源:
npm config get registry
命令執行後,輸出結果如下:
https://registry.npm.taobao.org/
五、npm查看當前鏡像配置
有時候,我們需要查看npm當前使用的鏡像配置,以便進行相應的修改。下面是查看當前鏡像配置的命令。
1、使用npm命令查看當前鏡像配置:
npm config list
命令執行後,輸出結果如下:
; cli configs user-agent = "npm/6.14.6 node/v12.18.1 win32 x64" ; userconfig C:\Users\HXX\.npmrc registry = "https://registry.npm.taobao.org/" ; builtin config undefined prefix = "C:\\Program Files\\nodejs\\node_global" cache-lock-stale = "60000" cache-lock-retries = "10" cache-lock-wait = "10000" cache-max = "Infinity" cache-min = "10" searchexclude = "" fetch-retries = "2" fetch-retry-factor = "10" fetch-retry-mintimeout = "10000" fetch-retry-maxtimeout = "60000" ; node bin location = C:\Program Files\nodejs\node.exe ; cwd = E:\HXX\git\test ; HOME = C:\Users\HXX ; "n