一、通過命令配置
1、設置淘寶鏡像源
npm config set registry https://registry.npm.taobao.org/
2、設置官方鏡像源
npm config set registry https://registry.npmjs.org
3、查看鏡像使用狀態(tài):
npm config get registry
如果返回https://registry.npm.taobao.org/,說明配置的是淘寶鏡像。文章來源:http://www.zghlxwxcb.cn/news/detail-504060.html
如果返回https://registry.npmjs.org/,說明配置的是淘寶鏡像。文章來源地址http://www.zghlxwxcb.cn/news/detail-504060.html
二、通過使用cnpm安裝
1、安裝cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
解決安裝卡頓或無法安裝:
# 注冊模塊鏡像
npm set registry https://registry.npm.taobao.org
// node-gyp 編譯依賴的 node 源碼鏡像
npm set disturl https://npm.taobao.org/dist
// 清空緩存
npm cache clean --force
// 安裝cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
2、使用cnpm
cnpm install xxx
到了這里,關(guān)于npm使用國內(nèi)淘寶鏡像的方法(兩種)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!