纱线有网络连接问题

IT技术 reactjs timeout package yarnpkg
2021-05-10 03:01:06

我今天早些时候尝试用纱线安装一个包,我得到了这个

yarn install
yarn install v1.9.4
[1/4] 🔍  Resolving packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.yarnpkg.com/eslint: getaddrinfo ENOTFOUND     registry.yarnpkg.com registry.yarnpkg.com:443".
info If you think this is a bug, please open a bug report with the information provided in "/Users/daviddragovacz/Documents/GitHub/react-    project-one/dragi/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

有人知道如何解决这个问题吗?我的网络似乎还可以,一点也不慢。

我尝试过的每个包都会发生这种情况。

包.json

{
    "name": "dragi",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "axios": "^0.18.0",
        "prop-types": "^15.6.2",
        "react": "^16.4.2",
        "react-dom": "^16.4.2",
        "react-redux": "^5.0.7",
        "react-router": "^4.3.1",
        "react-router-dom": "^4.3.1",
        "react-scripts": "1.1.5",
        "redux": "^4.0.0",
        "redux-devtools-extension": "^2.13.5",
        "redux-thunk": "^2.3.0",
        "semantic-ui-css": "^2.3.3",
        "semantic-ui-react": "^0.82.3",
        "validator": "^10.7.0"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject",
        "lint": "eslint src"
    },
    "devDependencies": {
        "eslint": "^5.5.0",
        "eslint-config-airbnb": "^17.1.0",
        "eslint-config-prettier": "^3.0.1",
        "eslint-plugin-import": "^2.14.0",
        "eslint-plugin-jsx-a11y": "^6.1.1",
        "eslint-plugin-prettier": "^2.6.2",
        "eslint-plugin-react": "^7.11.1",
        "prettier": "^1.14.2"
    },
    "proxy": "http://localhost:8080"
}

还有一个简短的说明:npm i 工作正常 - 只有纱线有问题

4个回答

尝试清除您的 cache

$ yarn cache clean
$ yarn // to install dependencies, no need for "yarn install"

方法二

$ yarn install --network-timeout 1000000

参考https://github.com/yarnpkg/yarn/issues/4890#issuecomment-358179301

尝试增加网络超时

yarn install --network-timeout 1000000

在 GitHub 问题https://github.com/yarnpkg/yarn/issues/4890上找到了这个

我遇到了同样的问题,并通过以下步骤解决了:

运行终端命令

  1. 清理 npm 缓存
  2. npm 缓存清理 --force
  3. 设置 http_proxy=
  4. 设置 https_proxy=
  5. 纱线配置删除代理
  6. npm config rm https-proxy
  7. npm 配置 rm 代理
  8. 重启你的终端
  9. 纱线 – 网络超时 100000

重启你的终端。

它对我有用。

我有一个不同的错误,但同样的网络连接问题。我通读了这个线程:https : //github.com/yarnpkg/yarn/issues/15

并最终卸载/重新安装 node/npm 解决了我的问题。也许您的节点安装也有问题?