Node与Npm国内最新镜像配置(淘宝镜像/清华大学镜像)

1.淘宝镜像:

node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/

2.清华大学镜像:

node_mirror: https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/
npm_mirror: https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/npm/

查看电脑当前镜像源:

npm get registry

临时更换镜像:

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

永久更换镜像

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

3.更换 nrm(Node Registry Manager)管理镜像源

nrm 是一个 npm 镜像源管理器,可以让你轻松地在不同的 npm 镜像源之间切换。

安装 nrm

npm install -g nrm

查看可用的镜像源

nrm ls

使用 nrm 切换到某个镜像源

nrm use npmmirror  # 使用 npmmirror 镜像源
# 或者使用 nrm use taobao 来使用淘宝的官方镜像源

4.更换 cnpm(一个由淘宝团队开发的 npm 客户端)

cnpm 是淘宝团队为解决国内网络问题而开发的 npm 客户端,它内置了淘宝的 npm 镜像。

安装 cnpm

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

使用 cnpm 安装包

cnpm install express

5.使用 yarn 来管理依赖(可选)

Yarn 是另一个流行的 JavaScript 包管理工具,它也可以配置使用国内的镜像源。

安装 yarn

npm install -g yarn

配置 yarn 使用淘宝镜像

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

注意:

确保在执行任何更改之前,备份当前的配置,以便在需要时可以轻松恢复。可以通过运行 npm config list -l 查看所有配置项及其值。如果要恢复默认设置,可以使用如下命令:

npm config delete registry # 删除 registry 设置,恢复为默认值(通常是官方源)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Technical genius

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值