一、通過命令配置
1、設置淘寶鏡像源
//舊
npm config set registry https://registry.npm.taobao.org/
//新
npm config set registry https://registry.npmmirror.com
舊域名將在 2022.06.30 號正式下線和停止 DNS 解析文章來源地址http://www.zghlxwxcb.cn/news/detail-829977.html
2、設置官方鏡像源
npm config set registry https://registry.npmjs.org
3、查看鏡像使用狀態(tài):
npm config get registry
二、通過使用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
文章來源:http://www.zghlxwxcb.cn/news/detail-829977.html
到了這里,關于npm使用國內(nèi)淘寶鏡像的方法(最新)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!