前景提要
因?yàn)楸娝苤脑?,我們從拉取從官方源拉取npm 依賴,經(jīng)常容易出現(xiàn)超時(shí),拉取失敗的情況。這個(gè)時(shí)候我們就非常有必要切換使用國內(nèi)源了,如淘寶源等
臨時(shí)使用
npm --registry https://registry.npm.taobao.org install XXX(模塊名)
全局設(shè)置
查看當(dāng)前源
npm config get registry
設(shè)置為淘寶源
npm config set registry https://registry.npm.taobao.org
還原默認(rèn)源
npm config set registry https://registry.npmjs.org/
使用cnpm
cnpm是一個(gè)命令,用它來代替npm文章來源:http://www.zghlxwxcb.cn/news/detail-703951.html
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install XXX(模塊名)
使用nrm
nrm 是一個(gè) npm 源管理器,允許你快速地在 npm源間切換文章來源地址http://www.zghlxwxcb.cn/news/detail-703951.html
npm install -g nrm
nrm use taobao
nrm ls # 查看當(dāng)前可用源命令
到了這里,關(guān)于npm設(shè)置國內(nèi)源(淘寶鏡像源),解決npm包下載速度慢的問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!