如何設(shè)置node.js模塊和其下載資源的鏡像

這篇文章將為大家詳細(xì)講解有關(guān)如何設(shè)置node.js模塊和其下載資源的鏡像,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)主要從事成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)奎文,10年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

后來研究發(fā)現(xiàn) npm 不僅可以設(shè)置 node.js 模塊倉(cāng)庫(kù)的代理, 同樣可以設(shè)置像 electron、phantomjs、 node-sass 等模塊的鏡像代理

一、設(shè)置淘寶鏡像 (共三種方法)

1.環(huán)境變量

Unix:

# electron
export ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
# phantomjs
export PHANTOMJS_cdnURL=https://npm.taobao.org/mirrors/phantomjs/
# node-sass
export SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/

Windows:

# electron
set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
# phantomjs
set PHANTOMJS_CDNURL=https://npm.taobao.org/mirrors/phantomjs/
# node-sass
set SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/

2.npm 執(zhí)行參數(shù)

# electron
npm install electron --electron-mirror=https://npm.taobao.org/mirrors/electron/
# phantomjs
npm install phantomjs --phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
# node-sass
npm install node-sass --sass-binary-site=https://npm.taobao.org/mirrors/node-sass/

3.使用本地(項(xiàng)目根目錄)或全局(用戶目錄).npmrc 配置

registry=https://registry.npm.taobao.org
electron_mirror=https://npm.taobao.org/mirrors/electron/
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/

二、使用代理

除了使用代理來解決,更暴力直接的方法就是使用梯子了。

 確保你要安裝的模塊倉(cāng)庫(kù)地址在代理PAC列表中或直接使用全局代理。npm 好像只支持 HTTP 代理

# 設(shè)置代理
npm config set proxy http://127.0.0.1:1085
# 安裝模塊
npm i --save-dev electron
# 刪除代理
npm config delete proxy

關(guān)于“如何設(shè)置node.js模塊和其下載資源的鏡像”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

文章題目:如何設(shè)置node.js模塊和其下載資源的鏡像
當(dāng)前路徑:http://muchs.cn/article12/pieegc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、網(wǎng)站建設(shè)網(wǎng)站收錄、網(wǎng)站改版、移動(dòng)網(wǎng)站建設(shè)網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化