yarn 网络连接有问题

yarn is having troubles with the network connection

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

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.

有人知道如何解决这个问题吗?我的网络好像还行,一点都不慢

我试过的每个包都会出现这种情况。

package.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 工作正常——只有 yarn 有问题

尝试清除您的 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

我在类似问题上重试了几次。

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

并最终 uninstalling/reinstalling node/npm 解决了我的问题。也许您的节点安装也有问题?

检查您的互联网速度/连接强度。我在不稳定的 public wifi 上遇到了这个问题。注意到这是一个不同的包,每次我尝试都会抛出错误。一旦我获得更快/更稳定的互联网,这个问题就消失了。 (包裹太大了,我的连接不好)。

我也收到了。

我运行 yarn install --no-lockfile 成功了,所以我再次删除了节点模块并删除了yarn.lock。它看起来像是 yarn 中的错误,因为 yarn 在我的应用程序的先前版本中没有问题。

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

运行终端命令

  1. 清理 npm 缓存
  2. npm 缓存清理 --force
  3. 设置http_proxy=
  4. 设置https_proxy=
  5. Yarn 配置删除代理
  6. npm 配置 rm https-代理
  7. npm 配置 rm 代理
  8. 重启终端
  9. 纱线
  10. Yarn –network-timeout 100000

重新启动您的终端。

对我有用。

我在使用 yarn install 时遇到了同样的网络重试问题,只需使用 yarn 就可以了。

可能是库最初使用的是 npm 而不是 yarn。在我的例子中,我必须使用 npm 而不是 yarn 安装所有东西。我删除了 yarn.lock 文件,然后:

npm install

如果您在 linux 中使用 WSL,只需将当前 ip 域添加到:C:\Windows\System32\drivers\etc\hosts 例如:

104.16.21.35    registry.yarnpkg.com

我已经尝试了很多:

  • npm clean cache
  • yarn clean cache
  • yarn config delete proxy
  • yarn config delete https-proxy
  • yarn config delete registry
  • yarn install --network-timeout 1000000

终于成功了!

在我的例子中,有一个隐藏文件 .npmrc,它的注册表指向另一个专用网络中的某个位置,而我的网络无法访问该位置。有一次,我在这个文件中注释掉了私有网络相关的条目,yarn install开始工作了。此外,生成了 yarn-error.log,其中包含此信息。

bash env 中的代理导致了我同样的问题。

在 运行 cmd unset HTTP_PROXY HTTPS_PROXY ALL_PROXY 之后,解决了这个问题。

尝试

yarn install --ignore-engines

以下对我有用

在终端上设置以下值

设置http_proxy=

设置https_proxy=

以下是对我有用的方法:

brew reinstall node

brew reinstall yarn

npm cache clean --force
 && yarn cache clean
 && yarn config delete proxy
 && yarn config delete https-proxy
 && yarn config delete registry

然后立即重启

我在构建节点容器时遇到了类似的问题。不完全是问题,但可能会帮助某人。选项 --network=host 是我的解决方案。

docker build --network=host --progress=plain .

yarn install --network-timeout 1000000

对我没用。


但是当我使用这个命令时

npm config rm proxy 
npm config rm https-proxy

解决我的问题

成功了!