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


被折叠的 条评论
为什么被折叠?



