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/
相关推荐
天才熊猫君1 小时前
配置与数据分离:一种可视化搭建的属性编辑方案
前端·javascript
林希_Rachel_傻希希1 小时前
web性能之相关路径——AI总结
前端·javascript·面试
竹林8181 小时前
用 wagmi v2 踩坑两天,我终于搞懂了多链钱包切换在 DeFi 前端中的正确姿势
前端·javascript
用户2136610035721 小时前
Vue项目搜索功能与面包屑导航
前端·javascript
星栈1 小时前
LiveView 的实时通信,爽是爽,但 PubSub 和广播也最容易把自己绕晕
前端·前端框架·elixir
用户2930750976691 小时前
告别关键词匹配,拥抱向量语义 —— RAG 搜索从零到一
前端
独孤留白1 小时前
从C到Rust:告别 C 的"指针 + 长度"手动模式
前端·rust
掘金安东尼2 小时前
中小厂前端候选人简历面试拆解:从 HR 面、技术面到主管面的双赢提问法
前端·面试
天平11 小时前
油猴脚本创建webworker踩坑记录
前端·javascript·typescript