error Error: write EPROTO...SSL routines:ssl3_read_bytes:tlsv1 alert internal...SSL alert number 80

一、问题描述

今天前端小伙伴反馈,有个项目编译失败,报错如下:

+ node -v
v16.17.0
+ npm -v
8.15.0
+ npm install -g yarn -registry=https://registry.npm.taobao.org

changed 1 package in 1m
+ yarn -v
1.22.21
+ yarn install
yarn install v1.22.21
[1/4] Resolving packages...
error Error: write EPROTO 139798789396352:error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1546:SSL alert number 80

    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Build step 'Execute shell' marked build as failure
SSH: Current build result is [FAILURE], not going to run.
Finished: FAILURE

二、解决方案

上面报错看着就有些似懂非懂的感觉了。好家伙,貌似能读懂的就一个SSL…

大致搜索了一下,也尝试了几种方法:
(1)npm cache clean --force
(2)npm config set ca ‘’
如果需要恢复原来设置:npm config delete canpm config set ca null
(3)npm config set strict-ssl false
如果需要恢复原来设置:npm config set strict-ssl true
(4)放弃yarn,改用npm
(5)更改registry:
更换镜像为:https://mirrors.huaweicloud.com/repository/npm/

设置过程又出现了另一个错误:

error Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1535:34)
    at TLSSocket.emit (node:events:513:28)
    at TLSSocket._finishInit (node:_tls_wrap:949:8)
    at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:730:12)

之后有小伙伴提醒,在2024年 1 月 22 日,淘宝原镜像域名(registry.npm.taobao.org)的 HTTPS 证书正式到期:

error Error: write EPROTO...SSL routines:ssl3_read_bytes:tlsv1 alert internal...SSL alert number 80_第1张图片
error Error: write EPROTO...SSL routines:ssl3_read_bytes:tlsv1 alert internal...SSL alert number 80_第2张图片

最新的淘宝镜像为https://registry.npmmirror.com

error Error: write EPROTO...SSL routines:ssl3_read_bytes:tlsv1 alert internal...SSL alert number 80_第3张图片

最新的配置淘宝镜像的淘宝官方提供的方法: npm config set registry https://registry.npmmirror.com
原来的 registry.npm.taobao.org 已替换为 registry.npmmirror.com ,当点击 registry.npm.taobao.org 会默认跳转到 registry.npmmirror.com
如果你想将npm的下载源恢复为默认的官方源,可以使用以下命令: npm config set registry https://registry.npmjs.org
你可以使用以下命令来查看当前npm的下载源设置: npm config get registry

随后便将 npm 源切换到新的源(registry.npmmirror.com):

npm config set registry https://registry.npmmirror.com
npm install
npm run build

运行后成功编译。由此看来,上述问题可能是原淘宝源HTTPS 证书正式到期导致,本次先行记录仅供参考,待后续有更多精力再补充。

三、问答

1.官方在哪公告需要切换新的淘宝镜像?

有的小伙伴是通过一些技术资讯获知需要更换新的淘宝镜像,同时也比较好奇官网在哪通知我们需要更新淘宝镜像的呢?

其实在这:【公告】淘宝 npm 域名即将切换 && npmmirror 重构升级

error Error: write EPROTO...SSL routines:ssl3_read_bytes:tlsv1 alert internal...SSL alert number 80_第4张图片

你可能感兴趣的:(开发问题,#,Vue开发问题,ssl,前端)