npm使用国内淘宝镜像的方法(两种)

一、通过命令配置

1、设置淘宝镜像源

npm config set registry https://registry.npm.taobao.org/

2、设置官方镜像源

npm config set registry https://registry.npmjs.org

3、查看镜像使用状态:

npm config get registry

如果返回https://registry.npm.taobao.org/,说明配置的是淘宝镜像。
如果返回https://registry.npmjs.org/,说明配置的是淘宝镜像。

二、通过使用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

相关推荐
এ慕ོ冬℘゜1 小时前
如何在 HTML 中嵌入音频和视频?
前端·html·音视频
变与不变80610 小时前
jQuery怎么使用
前端·javascript
神膘护体小月半10 小时前
flex 布局的 order 属性
前端·css
paopaokaka_luck10 小时前
流浪动物救助与收养系统(DeepSeek AI对话、 ECharts多维分析、救助流程衔接、领养与回访衔接、 捐赠确认与公示、志愿者协作)
java·前端·javascript·人工智能·mysql·echarts·推荐算法
仰望.10 小时前
vue 表格组件 vxe-table 树表格懒加载支持拖拽排序的详细用法
前端·javascript·vue.js·vxe-table
前端 贾公子10 小时前
vite-plugin-uni-manifest 升级指南
前端
小码哥_常10 小时前
iPhone 用户传了张 HEIC,我的前端崩了
前端
小码哥_常11 小时前
你发的原图可能暴露你家地址——聊聊图片 EXIF 隐私
前端
java1234_小锋11 小时前
【技术专题】CSS3 网页技术 - CSS3 优先级
前端·css·css3
鸿蒙开发12 小时前
共享 Schema 与 SchemaFactory
前端·后端·harmonyos