gpt4 book ai didi

npm install : FetchError: request to http://registry. npmjs.org/... 失败,原因:读取 ECONNRESET

转载 作者:行者123 更新时间:2023-12-03 16:51:07 26 4
gpt4 key购买 nike

尝试使用 npm 安装任何节点包会挂起大约 5 分钟,然后出现 ECONNRESET 网络错误。我最近一直在其他项目中使用 npm,它运行良好,但现在不适用于任何项目(包括干净的 npm init)

npm i ws

这是在我的家庭网络上运行的 Raspberry pi 3 上,没有代理要求。 linux 和 windows 的所有其他机器都工作正常。
npm -v = 6.4.1

我尝试了以下方法:
  • npm i ws这给了我 ECONNRESET 错误(见下文)
  • Curl https://registry.npmjs.org/& Curl https://registry.npmjs.org/ws两者都返回正确的 json 响应
  • 删除任何代理设置
  •     npm config rm proxy
    npm config rm https-proxy
    npm config set registry http://registry.npmjs.org/
  • 重启等

  • 完整的错误日志:
    npm i ws --save --verbose
    npm info it worked if it ends with ok
    npm verb cli [ '/home/pi/.nvm/versions/node/v8.16.0/bin/node',
    npm verb cli '/home/pi/.nvm/versions/node/v8.16.0/bin/npm',
    npm verb cli 'i',
    npm verb cli 'ws',
    npm verb cli '--save',
    npm verb cli '--verbose' ]
    npm info using npm@6.4.1
    npm info using node@v8.16.0
    npm verb npm-session 0a9bedb5def7f4a1
    npm timing stage:rollbackFailedOptional Completed in 6ms
    npm timing stage:runTopLevelLifecycles Completed in 1146975ms
    npm verb type system
    npm verb stack FetchError: request to http://registry.npmjs.org/ws failed, reason: read ECONNRESET
    npm verb stack at ClientRequest.req.on.err (/home/pi/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
    npm verb stack at emitOne (events.js:116:13)
    npm verb stack at ClientRequest.emit (events.js:211:7)
    npm verb stack at Socket.socketErrorListener (_http_client.js:401:9)
    npm verb stack at emitOne (events.js:116:13)
    npm verb stack at Socket.emit (events.js:211:7)
    npm verb stack at emitErrorNT (internal/streams/destroy.js:66:8)
    npm verb stack at _combinedTickCallback (internal/process/next_tick.js:139:11)
    npm verb stack at process._tickCallback (internal/process/next_tick.js:181:9)
    npm verb cwd /home/pi/projects/picamera/node_server
    npm verb Linux 4.19.37-v7+
    npm verb argv "/home/pi/.nvm/versions/node/v8.16.0/bin/node" "/home/pi/.nvm/versions/node/v8.16.0/bin/npm" "i" "ws" "--save" "--verbose"
    npm verb node v8.16.0
    npm verb npm v6.4.1
    npm ERR! code ECONNRESET
    npm ERR! errno ECONNRESET
    npm ERR! network request to http://registry.npmjs.org/ws failed, reason: read ECONNRESET
    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'
    npm verb exit [ 1, true ]
    npm timing npm Completed in 1148813ms

    npm ERR! A complete log of this run can be found in:
    npm ERR! /home/pi/.npm/_logs/2019-05-10T23_28_17_769Z-debug.log

    最佳答案

    首先检查以下内容:

    ping registry.npmjs.org

    您将通过以下方式了解 IP 地址:

    PING registry.npmjs.org (104.16.20.35) 56(84) 字节数据。
    然后
    sudo vi /etc/hosts
    104.16.20.35 registry.npmjs.org

    然后尝试执行以下操作
    npm install

    关于npm install : FetchError: request to http://registry. npmjs.org/... 失败,原因:读取 ECONNRESET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56089238/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com