国内可用 npm 源镜像

npm 官方原始镜像:https://registry.npmjs.org
淘宝 NPM 镜像:https://registry.npmmirror.com
阿里云 NPM 镜像:https://npm.aliyun.com
腾讯云 NPM 镜像:https://mirrors.cloud.tencent.com/npm
华为云 NPM 镜像:https://mirrors.huaweicloud.com/repository/npm
网易 NPM 镜像:https://mirrors.163.com/npm
中科院大学开源镜像站:http://mirrors.ustc.edu.cn
清华大学开源镜像站:https://mirrors.tuna.tsinghua.edu.cn

使用方法

修改成腾讯云镜像源

1、命令

npm config set registry http://mirrors.cloud.tencent.com/npm/

2. 验证命令

npm config get registry
如果返回 http://mirrors.cloud.tencent.com/npm/,说明镜像配置成功。

修改成淘宝镜像源

1. 命令

npm config set registry https://registry.npmmirror.com

2. 验证命令

npm config get registry
如果返回 https://registry.npmmirror.com,说明镜像配置成功。

修改成华为云镜像源

1. 命令

npm config set registry https://mirrors.huaweicloud.com/repository/npm/

2. 验证命令

npm config get registry
如果返回 https://mirrors.huaweicloud.com/repository/npm/,说明镜像配置成功。

通过使用淘宝定制的 cnpm 安装

1. 安装 cnpm

npm install -g cnpm --registry=https://registry.npmmirror.com

2. 使用 cnpm

cnpm install xxx

淘宝 npm

淘宝 npm 镜像站全新上线:

Web界面地址:https://npmmirror.com

npm 客户端使用地址:https://registry.npmmirror.com


其他进阶操作

使用 nrm 切换镜像源

什么是 nrm?

nrm 是一个 npm 源管理器,允许你快速地在 npm 源间切换。

安装 nrm
npm install -g nrm
使用 nrm

查看可选的源

nrm ls
切换源

如果要切换到 taobao 源,执行命令

nrm use taobao
测试速度
nrm test

恢复官方镜像

如果需要解除镜像并恢复到官方源,请执行以下命令:

npm config set registry https://registry.npmjs.org
轩源的网络日志微信公众号:源码跳动
微信公众号: 源码跳动
轩源和他的朋友们②群0914
更多技术讨论加微信群

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注