Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to ‘0‘ makes TLS connections and HTTPS

ModelEngine·创作计划征文活动 10w+人浏览 1.5k人参与

windows 环境
yarn install
➤ YN0000: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to ‘0’ makes TLS connections and HTTPS requests insecure by disabling certificate verification.➤ YN0000: · Yarn 4.9.4
➤ YN0000: ┌ Resolution step
➤ YN0001: │ RequestError: unable to verify the first certificate
RequestError: unable to verify the first certificate 这个错误表示 Yarn 在尝试下载依赖包时无法验证服务器的 SSL 证书。

PS D:\a_GenAI\agent_guanlan\gaia> yarn install
>>
➤ YN0000: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.➤ YN0000: · Yarn 4.9.4
➤ YN0000: ┌ Resolution step
➤ YN0001: │ RequestError: unable to verify the first certificate
    at ClientRequest. <anonymous> (D:\a_GenAI\agent_guanlan\gaia\.yarn\releases\yarn-4.9.4.cjs:146:14258)
    at Object.onceWrapper (node:events:634:26)
    at ClientRequest.emit (node:events:531:35)
    at c.emit (D:\a_GenAI\agent_guanlan\gaia\.yarn\releases\yarn-4.9.4.cjs:141:22975)
    at emitErrorEvent (node:_http_client:101:11)
    at TLSSocket.socketErrorListener (node:_http_client:504:5)
    at TLSSocket.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at TLSSocket.onConnectSecure (node:_tls_wrap:1677:34)
    at TLSSocket.emit (node:events:519:28)
    at TLSSocket._finishInit (node:_tls_wrap:1076:8)
    at ssl.onhandshakedone (node:_tls_wrap:862:12)
➤ YN0000: └ Completed in 1s 765ms

yarn version
4.9.4
报错解决流程
1.set NODE_TLS_REJECT_UNAUTHORIZED=1
不生效
2. npm config set strict-ssl false
不生效,这说明 Yarn 的证书验证机制没有受到 npm 配置的影响,因为 Yarn 使用自己的配置系统和网络请求逻辑。npm config 对 Yarn 无效。

最终解决方案
在项目中设置 .yarnrc.yml 文件
在这里插入图片描述
增加

unsafe-http-whitelist: ["*"]

enableStrictSsl: false

yarn install 报错
Usage Error: Unrecognized or legacy configuration settings found: unsafe-http-whitelist - run “yarn config” to see the list of settings supported in Yarn (in D:\a_GenAI\agent_guanlan\gaia.yarnrc.yml)
使用命令 yarn config get
➤ YN0034: Invalid configuration key “unsafe-http-whitelist” in /D:/a_GenAI/agent_guanlan/gaia/.yarnrc.yml

删掉只写,问题解决

enableStrictSsl: false

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT_Octopus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值