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/
相关推荐
ᖰ・◡・ᖳ19 分钟前
JavaScript:神奇的ES6之旅
前端·javascript·学习·es6
app出海创收老李24 分钟前
海外独立创收日记(5)-上个月收入回顾与本月计划
前端·后端·程序员
前端Hardy25 分钟前
HTML&CSS:一眼心动的 SVG 时钟
前端·javascript·css
TTGGGFF27 分钟前
Streamlit:CSS——从基础到实战美化应用
前端·css
app出海创收老李36 分钟前
海外独立创收日记(4)-第一笔汇款
前端·后端·程序员
Takklin37 分钟前
React JSX 转换原理与 GSR 实现解析
前端·react.js
苏打水com1 小时前
字节跳动前端业务:从「短视频交互」到「全球化适配」的技术挑战
前端·音视频
深蓝电商API1 小时前
不止是 Python:聊聊 Node.js/Puppeteer 在爬虫领域的应用
爬虫·python·node.js
又是忙碌的一天1 小时前
前端学习 JavaScript
前端·javascript·学习
Jagger_2 小时前
Cursor + Apifox MCP:告别手动复制接口,AI 助你高效完成接口文档开发
前端