V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
monster1priest
V2EX  ›  程序员

npm 使用 https 会报错

  •  
  •   monster1priest · 347 天前 · 1150 次点击
    这是一个创建于 347 天前的主题,其中的信息可能已经有所发展或是发生改变。

    clash 开的增强模式,终端已设置export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

    npm 的 registry 如下设置为 http 时:

    registry = "http://registry.npmjs.org/"

    可以成功安装,但是会显示warning

    npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
    
    npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
    

    npm 的 registry 换成 https 时:

    registry = "https://registry.npmjs.org/"

    会报错:

    npm ERR! code ECONNRESET
    npm ERR! errno ECONNRESET
    npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/@types%2fnode: aborted
    npm ERR! network This is a problem related to network connectivity.
    npm ERR! network In most cases you are behind a proxy or have bad network settings.
    npm ERR! network
    npm ERR! network If you are behind a proxy, please make sure that the
    npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
    
    9 条回复    2023-05-15 14:55:53 +08:00
    november
        1
    november  
       347 天前
    同样,国内使用 https 安装 github 上的项目的时候,也是报错。不过多次安装总有一次成功的。

    另外,我用的 yarn ,yarn 打印出 registry 的时候,是 yarn 的地址,但是实际安装却是走的腾讯的源,没找到什么说法。
    2218675712
        2
    2218675712  
       347 天前
    建议 npm 不设置代理,clash 开 tun 模式
    ChrisFreeMan
        3
    ChrisFreeMan  
       347 天前
    老毛病了,一般都是加密 VPN 的性能问题(连接上限瓶颈?),我用一些非针对 GFW 加密的 VPN 是可以很流畅的使用 npm 的,但是很快会被识别然后 IP 被封掉,头疼。
    lete
        4
    lete  
       347 天前
    要不试试这个看行不行,https://github.com/CreateWheel/mini-nrm
    ncepuzs
        5
    ncepuzs  
       347 天前
    开了增强模式为什么还要设置 http_proxy 环境变量?虽然感觉应该不会冲突……
    看报错信息似乎要通过 npm config 设置 proxy ,没用过
    另外,可以先尝试换大陆镜像源
    C47CH
        6
    C47CH  
       347 天前
    用 https_proxy 环境变量和 xray 没出过问题。
    Track13
        7
    Track13  
       347 天前 via Android
    clash 开 tun 吧
    duzhuo
        8
    duzhuo  
       346 天前 via Android
    coyoteer
        9
    coyoteer  
       346 天前
    把你的 clash 关了,感觉设国内镜像源和 clash 之间有冲突,pip 有时也会这样
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1651 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:52 · PVG 00:52 · LAX 09:52 · JFK 12:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.