npm config set registry切换npm镜像源

要切换 npm 镜像源,可以使用 npm config set registry 命令。以下是切换到官方的 npm 镜像源的步骤:

  • 查看当前 npm 镜像源:

    bash 复制代码
    npm config get registry
  • 如果当前的镜像源不是官方的 npm 镜像源(https://registry.npmjs.org/),则需要切换。
    切换到官方的 npm 镜像源:

    bash 复制代码
    npm config set registry https://registry.npmjs.org/
  • 验证切换是否成功

    bash 复制代码
    npm config get registry

如果输出为 https://registry.npmjs.org/,则表示切换成功。

  • 切换到其他镜像源的步骤类似,只需要将 npm config set registry 命令中的 URL 替换为相应的镜像源的 URL 即可。

    • 例如,切换到淘宝的 npm 镜像源,可以使用以下命令:
    bash 复制代码
    npm config set registry https://registry.npm.taobao.org/
  • 完成切换后,再次尝试运行 sudo npm install -g @vue/cli 命令,看看是否能够顺利进行安装。

国内npm源:

bash 复制代码
npm 官方原始镜像网址是:https://registry.npmjs.org/
淘宝 NPM 镜像:https://registry.npm.taobao.org
阿里云 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/
相关推荐
小小龙学IT4 分钟前
HTMX:让 HTML 重新成为前端核心的超轻量动态交互库
前端·html·交互
星栈4 分钟前
写 Makepad Demo 不难,难的是把它写成项目
前端·rust
用户059540174466 分钟前
localStorage清除策略踩坑实录:一个过期的token让我排查了3小时
前端·css
Nanachi8 分钟前
跨框架的前端源码定位,再加上点LLM
前端
人无远虑必有近忧!28 分钟前
fetch请求图片报跨域
前端·javascript
谢院柯28 分钟前
解决修改 node_modules 依赖库源码后重复安装问题的几种方案
前端
疯狂打码的少年31 分钟前
【程序语言与编译】NFA转DFA(子集构造法)
前端·笔记
半只小闲鱼33 分钟前
合并多个excel文件到一个文件中
前端·python·数据分析
fobwebs43 分钟前
Chrome谷歌浏览器多开教程,如何在电脑上同时登录多个GMAIL账号
前端·chrome·多开·同时登录多个gmail
前端 贾公子1 小时前
小程序蓝牙打印探索与实践 (最终章)
前端·微信小程序·小程序