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/
相关推荐
天宇&嘘月2 小时前
web第三次作业
前端·javascript·css
小王不会写code3 小时前
axios
前端·javascript·axios
发呆的薇薇°4 小时前
vue3 配置@根路径
前端·vue.js
luckyext4 小时前
HBuilderX中,VUE生成随机数字,vue调用随机数函数
前端·javascript·vue.js·微信小程序·小程序
小小码农(找工作版)4 小时前
JavaScript 前端面试 4(作用域链、this)
前端·javascript·面试
前端没钱4 小时前
前端需要学习 Docker 吗?
前端·学习·docker
前端郭德纲4 小时前
前端自动化部署的极简方案
运维·前端·自动化
海绵宝宝_5 小时前
【HarmonyOS NEXT】获取正式应用签名证书的签名信息
android·前端·华为·harmonyos·鸿蒙·鸿蒙应用开发
码农土豆5 小时前
chrome V3插件开发,调用 chrome.action.setIcon,提示路径找不到
前端·chrome
鱼樱前端5 小时前
深入JavaScript引擎与模块加载机制:从V8原理到模块化实战
前端·javascript