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/
相关推荐
玲小珑4 分钟前
Next.js 教程系列(二十五)测试策略:单元、集成与端到端测试
前端·next.js
谢小飞13 分钟前
一款解压的3D方块加载动画效果
前端·three.js
阿虎儿19 分钟前
Modern Node.js Patterns for 2025(2025 年现代 Node.js 模式)
javascript·node.js
二狗哈27 分钟前
制作一款打飞机游戏87:最后冲刺
java·前端·游戏
JarvanMo33 分钟前
移动开发已死——除非你.......
前端
掘金安东尼1 小时前
独立开发/自由职业/远程工作:这年头不上班也能过挺好!!
前端·面试·github
江城开朗的豌豆1 小时前
告别Class组件!用useEffect玩转React生命周期
前端·javascript·react.js
江城开朗的豌豆1 小时前
React状态管理:从Context到Redux,我的选型心得
前端·javascript·react.js
子洋1 小时前
Ubuntu 安装 Nginx
前端·后端·nginx
晓得迷路了1 小时前
栗子前端技术周刊第 93 期 - ECharts 6.0、Vite 领域新动态汇总、Cursor 1.4...
前端·javascript·vite