執行 npm 各種命令的時候,默認是去 npm 官方鏡像源獲取需要安裝的具體軟件信息
以下命令查看當前使用的鏡像源
npm config get registry
默認源地址在國外,從國內訪問的速度肯定比較慢
如何修改鏡像源
阿里旗下維護着一個完整的 npm 鏡像源 https://registry.npm.taobao.org/
1. 臨時修改
npm install 軟件名 --registry https://registry.npm.taobao.org/
2. 全局修改
npm config set registry https://registry.npm.taobao.org/
3. 使用第三方軟件快速修改、切換 npm 鏡像源
nrm NPM registry manager
nrm 不僅可以快速切換鏡像源,還可以測試自己網絡訪問不同源的速度
安裝 nrm
npm install -g nrm
列出當前可用的所有鏡像源
nrm ls
npm ----- https://registry.npmjs.org/
cnpm ---- http://r.cnpmjs.org/
taobao -- https://registry.npm.taobao.org/
nj ------ https://registry.nodejitsu.com/
rednpm -- http://registry.mirror.cqupt.edu.cn
skimdb -- https://skimdb.npmjs.com/registry
使用淘寶鏡像源
nrm use taobao
測試訪問速度
nrm test taobao
轉自鏈接:https://learnku.com/articles/15975/npm-accelerate-and-modify-mirror-source-in-china