Yarn在网络连接方面出现了问题。

48

今天早些时候,我尝试使用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 会出现问题。


请问您能否分享一下您的 package.json 文件呢? - Adeel Imran
很遗憾,Yarn没有任何调试信息。能够看到它所遇到的网络问题将是很好的。 - user959690
使用 Node 10 或更高版本解决了我的“网络连接”问题。 - Troglo
25个回答

0
我遇到了超时问题,对我来说问题是图像是从M2 MacBook构建的。修复方法是在docker build命令中添加--platform linux/amd64参数: docker build --platform linux/amd64

0

我尝试了很多:

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

最终它起作用了!


0

已经尝试重新安装/安装 yarn,但不起作用,对我来说问题出在 nvm 缓存中:

nvm cache clear

清理后问题得到解决。


0
在Mac上,我尝试清除缓存,重新安装VSCode,但都没有解决我的问题,而且我没有连接任何VPN。
连接到VPN解决了这个问题。

这对我来说很有效,谢谢!你是用SLT连接吗? - undefined

-1
我也遇到了这个问题,但在我的情况下是权限问题,所以我通过解决了它。
sudo yarn install

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接