NPM 和 Yarn 使用國內淘寶鏡像源提升各依賴安裝速度


因受國內的環境影響,導致了很多速度起不來,所以需要安裝國內鏡像。

配置 NPM 的淘寶鏡像源加速

打開poweshellcmd工具,輸入以下命令:

npm config set registry https://registry.npm.taobao.org
npm config set disturl https://npm.taobao.org/dist
npm config set electron_mirror https://npm.taobao.org/mirrors/electron/
npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/

然后輸入命令

npm get registry

得到返回結果為 https://registry.npm.taobao.org/ 說明注冊成功。

windows 下 Yarn 安裝與使用

如果你還沒有安裝 Yarn,通過訪問https://classic.yarnpkg.com/latest.msi,下載安裝包。雙擊安裝后,輸入命令

yarn -v

返回版本號1.22.4即表示成功。

Yarn 注冊淘寶鏡像源加速

打開poweshellcmd工具,輸入以下命令:

yarn config set registry https://registry.npm.taobao.org -g
yarn config set disturl https://npm.taobao.org/dist -g
yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ -g
yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g
yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/ -g
yarn config set chromedriver_cdnurl https://cdn.npm.taobao.org/dist/chromedriver -g
yarn config set operadriver_cdnurl https://cdn.npm.taobao.org/dist/operadriver -g
yarn config set fse_binary_host_mirror https://npm.taobao.org/mirrors/fsevents -g

然后輸入命令,查看當前地址源:

yarn config get registry

得到返回結果為 https://registry.npm.taobao.org/ 說明注冊成功。

本文作為資源記錄,轉載自:https://mp.weixin.qq.com/s/3LQVKnEY4Fk7UTtMBN5YxA


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM