- 有時(shí)候,我們通過
npm install進(jìn)行項(xiàng)目初始化,會(huì)由于“天朝墻”的原因,可能會(huì)導(dǎo)致下載速度慢,無法下載等等問題出現(xiàn)。
好在現(xiàn)在有很多國內(nèi)鏡像,也有一個(gè)幫助我們隨意切換 npm 鏡像的工具: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/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
nrm use taobao
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/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
- 但是有個(gè)弊端,當(dāng)項(xiàng)目被其他人克隆后,每個(gè)人都要進(jìn)行nrm,有點(diǎn)麻煩,可以在根目錄創(chuàng)建添加
.npmrc 文件:
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org
- 直接進(jìn)行
npm install 時(shí),npm 都會(huì)根據(jù)跟目錄下 .npmrc 中的配置進(jìn)行依賴的安裝。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。