npm install报错:淘宝镜像证书过期

npm install报错:淘宝镜像证书过期

近期使用npm淘宝镜像新建项目或依赖时出现报错:

npm ERR! request to https://registry.npm.taobao.org/xxx failed, reason: certificate has expired

错误原因:

早在 2021 年,淘宝就发文称,npm 淘宝镜像已经从 http://registry.npm.taobao.org 切换到了 http://registry.npmmirror.com。旧域名也将于 2022 年 5 月 31 日停止服务(直到 HTTPS 证书到期才真正不能用了)

2024年1 月 22 日,淘宝原镜像域名(http://registry.npm.taobao.org)的 HTTPS 证书正式到期,导致旧的 npm 淘宝镜像在使用时出错了。

解决方案:

  1. 查看当前的npm镜像设置
typescript 复制代码
npm config get registry
  1. 切换新源
typescript 复制代码
npm config set registry https://registry.npmmirror.com
  1. 查看新源是否设置成功
typescript 复制代码
npm config get registry
  1. 可以正常安装需要的工具了

国内镜像还有如下,根据自己的需要使用:

腾讯:http://mirrors.cloud.tencent.com/npm/

华为:https://mirrors.huaweicloud.com/repository/npm/

中科大镜像:https://registry.npmjs.org/

相关推荐
Lank_M41 分钟前
白底都占八成,PNG 为何只在图表页赢过 JPG
前端
张一凡9342 分钟前
给 Coding Agent 加一道"架构闸门":Jin 是如何做到"先审架构、再写代码、不漂移"的
前端·后端·agent
Linye42 分钟前
AI 写的 HTML 原型全是空壳?聊聊真实 DOM 交互避坑
前端·人工智能
ZANE1 小时前
纯前端实现的 PDF 与图片互相转换工具技术实现
前端
Swot1 小时前
SvelteKit Remote Functions 使用指南
前端·后端
Cooper251 小时前
三源热榜去重加 AI 摘要:URL 唯一键踩出的三个坑
前端·python
Yk酱228402 小时前
A2UI探索随笔-技术选型
前端
前端繁华如梦2 小时前
# 从 73000 行压缩代码到 TypeScript 模块化:我把一个 Three.js FPS 游戏 1:1 复刻了一遍
前端
Penge6662 小时前
React Context 详解:从 Props 传递到跨组件状态共享
前端
Penge6662 小时前
React 事件处理:bind(this) 原理与实际开发常用写法
前端