npm、yarn、pnpm设置国内镜像源

你好,我是悦创。

我的博客网站阅读更佳:https://bornforthis.cn/blog/vuepress/08.html

默认的官方镜像:https://registry.npmjs.org,切换国内淘宝镜像,访问下载更快。

1. npm 设置

::: code-tabs

  1. 查看源
npm config get registry
  1. 设置淘宝源
npm config set registry https://registry.npmmirror.com/
  1. 切回官方镜像
npm config set registry https://registry.npmjs.org/
  1. npm 临时使用
# 上面那种设置是全局的,以后每次都会自动读取已经设置好的源,如果只是一次性使用,可以使用下面的命令
npm --registry https://registry.npmmirror.com install XXX(模块名)

2. yarn 设置

  1. 查看源
yarn config get registry
  1. 设置淘宝源
yarn config set registry https://registry.npmmirror.com
  1. 切回官方镜像
yarn config set registry https://registry.yarnpkg.com

3. pnpm 设置

  1. 查看源
pnpm config get registry
  1. 设置淘宝源
pnpm config set registry https://registry.npmmirror.com
  1. 切回官方镜像
pnpm config set registry https://registry.npmjs.org

4. 常见问题

npm 修改了下载源,仍然是之前的下载源。或者下载失败、下载到某处停止不动。可以进行如下操作。

  1. 清除缓存
  2. 将对应项目中的 node_modules 文件夹以及 package-lock.json 文件删除。
  3. 执行安装 + 需要的下载源。
  • 11
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

AI悦创|编程1v1

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

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

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

打赏作者

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

抵扣说明:

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

余额充值