国内 npm 镜像源推荐

国内 npm 镜像源推荐

除了常用的淘宝镜像(https://registry.npmmirror.com),还有以下国内 npm 镜像源可供选择:


1. CNPM(阿里云)
  • 地址:https://r.cnpmjs.org/
  • 特点:
    • 由 cnpm 提供,支持同步 npm 官方仓库。
    • 提供更快的下载速度和稳定性。

使用方法:

bash 复制代码
npm config set registry https://r.cnpmjs.org/

2. 京东镜像(JFrog Artifactory)
  • 地址:https://registry.jfrog.org/npm/registry
  • 特点:
    • 由京东提供,基于 JFrog Artifactory。
    • 支持高并发访问,适合企业级用户。

使用方法:

bash 复制代码
npm config set registry https://registry.jfrog.org/npm/registry

3. 腾讯云镜像
  • 地址:https://mirrors.cloud.tencent.com/npm/
  • 特点:
    • 由腾讯云提供,适用于使用腾讯云服务的开发者。
    • 提供稳定的下载速度。

使用方法:

bash 复制代码
npm config set registry https://mirrors.cloud.tencent.com/npm/

4. 华为云镜像
  • 地址:https://repo.huaweicloud.com/repository/npm/
  • 特点:
    • 由华为云提供,适用于使用华为云服务的开发者。
    • 提供快速的国内访问速度。

使用方法:

bash 复制代码
npm config set registry https://repo.huaweicloud.com/repository/npm/

5. 网易镜像
  • 地址:http://mirrors.163.com/npm/
  • 特点:
    • 由网易提供,适用于国内用户。
    • 提供稳定的下载速度。

使用方法:

bash 复制代码
npm config set registry http://mirrors.163.com/npm/

切换镜像源后验证

切换镜像源后,可以通过以下命令验证是否成功:

bash 复制代码
npm config get registry

如果输出为你设置的镜像源地址,则说明切换成功。


注意事项

  1. 临时使用镜像源

    如果只想在当前会话中使用某个镜像源,可以添加 --registry 参数。例如:

    bash 复制代码
    npm install electron --save-dev --registry=https://registry.npmmirror.com
  2. 恢复默认源

    如果需要恢复为官方 npm 源,可以运行以下命令:

    bash 复制代码
    npm config set registry https://registry.npmjs.org/
  3. 选择合适的镜像源

    根据你的网络环境和地理位置选择最合适的镜像源。通常情况下,淘宝镜像(https://registry.npmmirror.com)是大多数开发者的首选。

希望这些信息对你有所帮助!

相关推荐
子兮曰13 小时前
OpenClaw入门:从零开始搭建你的私有化AI助手
前端·架构·github
吴仰晖13 小时前
使用github copliot chat的源码学习之Chromium Compositor
前端
1024小神13 小时前
github发布pages的几种状态记录
前端
朝朝暮暮an14 小时前
Day 3|Node.js 异步模型 & Promise / async-await(Part 1)
node.js
不像程序员的程序媛15 小时前
Nginx日志切分
服务器·前端·nginx
北原_春希15 小时前
如何在Vue3项目中引入并使用Echarts图表
前端·javascript·echarts
尽意啊15 小时前
echarts树图动态添加子节点
前端·javascript·echarts
吃面必吃蒜15 小时前
echarts 极坐标柱状图 如何定义柱子颜色
前端·javascript·echarts
O_oStayPositive15 小时前
Vue3使用ECharts
前端·javascript·echarts
竹秋…15 小时前
echarts自定义tooltip中的内容
前端·javascript·echarts