48

I tried to install a package with yarn earlier today and I got this

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.

does anybody know how to fix this? My network seems to be okay, not slow at all.

It happens with every package I tried.

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"
}

Also a quick note: npm i works fine - only yarn is having issues

tk421
  • 5,775
  • 6
  • 23
  • 34
dragi
  • 1,462
  • 5
  • 16
  • 28

17 Answers17

71

Try clearing your cache

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

Approach 2

$ yarn install --network-timeout 1000000

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

Adeel Imran
  • 13,166
  • 8
  • 62
  • 77
  • 1
    Still the same unfortunately.. Thanks for the tip though! :) – dragi Sep 02 '18 at 09:59
  • Doesn't help.. In the meantime I tried to remove the lock file and node_modules folder but that didnt work either – dragi Sep 02 '18 at 10:56
  • Hmm this is strange. Try extending the time `yarn install --network-timeout 9000000` like this. Also remove your `node_modules` & lock file again. Before doing this. 3rd times the charm. :) – Adeel Imran Sep 02 '18 at 10:58
  • Still the same.. I checked https://status.npmjs.org/ and it says that some things are wrong at the moment and the Registry Reads have some outages now. Could this be the reason? – dragi Sep 02 '18 at 11:09
  • I don't think that is the reason, can you add your `package.json` in the question as well. I'd like to have a look at it. – Adeel Imran Sep 02 '18 at 11:11
  • Hey, I added the package.json – dragi Sep 02 '18 at 13:50
  • The package.json install smoothly at my end. I ended up finding a resource that will help you. Check this comment out https://github.com/yarnpkg/yarn/issues/5259#issuecomment-379769451 as a last attempt. – Adeel Imran Sep 02 '18 at 13:57
  • This answer spare me lot of time, using first raspberry version yarn install fall in timeout exception due to network and disk write limit (raspberry first version). Thanks dude. – Ashbay Nov 29 '20 at 20:04
16

Try increasing network timeout

yarn install --network-timeout 1000000

found this on GitHub issues https://github.com/yarnpkg/yarn/issues/4890

ramki
  • 461
  • 3
  • 7
  • 1
    where is that flag documented? https://yarnpkg.com/en/docs/cli/ or https://yarnpkg.com/en/docs/cli/install don't have it – jcollum Jun 05 '19 at 21:36
  • 1
    I can find it only in `yarn --help` – ramki Jun 10 '19 at 12:27
  • 1
    The [default value](https://github.com/yarnpkg/yarn/blob/3119382885ea373d3c13d6a846de743eca8c914b/src/constants.js#L40) is currently 30,000, i.e. 30 seconds. – Ninjakannon Nov 06 '22 at 17:40
10

I had the same issue and solved by following steps:

Run the terminal command

  1. clean npm cache
  2. npm cache clean --force
  3. set http_proxy=
  4. Set https_proxy=
  5. yarn config delete proxy
  6. npm config rm https-proxy
  7. npm config rm proxy
  8. Restart your terminal
  9. yarn
  10. yarn –network-timeout 100000

Restart your terminal.

it worked for me. #HappyCoding

Avinash Kesari
  • 173
  • 1
  • 7
5

If you are using WSL for linux just add the current ip domain in: C:\Windows\System32\drivers\etc\hosts e.g:

104.16.21.35    registry.yarnpkg.com
3

i had a different error, but the same network connection issue. i read through this thread: https://github.com/yarnpkg/yarn/issues/15

and ended up uninstalling/reinstalling node/npm which fixed my issue. maybe there's something wrong with your node installation too?

matcha
  • 81
  • 1
  • 9
2

It may be the library was originally using npm instead of yarn. In my case I had to install everything with npm instead of yarn. I removed the yarn.lock file and then:

npm install
Isaac Pak
  • 4,467
  • 3
  • 42
  • 48
2

proxy in bash env caused my same problem.

after running cmd unset HTTP_PROXY HTTPS_PROXY ALL_PROXY, fixed this problem.

Ridox
  • 1,073
  • 13
  • 18
  • unset all proxy environment variable fixed this issue, in my case. includeing above for me; `$ unset http_proxy https_proxy` – agfe2 Dec 24 '21 at 02:32
2

here's what worked for me:

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

then RESTART immediately.

Osama Rashid
  • 1,000
  • 8
  • 9
1

Check your internet speed / strength of connection. I had this problem while I was on a spotty public wifi. Noticed that it was a different package that threw the error each time I tried. And once I got faster / more stable internet this problem went away. (The packages were too large for my poor connection).

PolarisTLX
  • 329
  • 4
  • 18
  • This was my problem. I am trying to do `yarn --production` from a hotel, which results in the same error as the OP. But, copying my code to a remote server and doing`yarn --production` there solved the issue. – MikeyE Jun 23 '23 at 20:55
1

In my case, there was a hidden file .npmrc that had the registry pointed to a location in another private network, which my network did not have access to. Once, I commented out the private network related entries in this file, yarn install started working. Also, yarn-error.log was generated, that had this information.

Binita Bharati
  • 5,239
  • 1
  • 43
  • 24
0

retrying few times worked out for me on similar issue.

Jackie
  • 25,199
  • 6
  • 33
  • 24
0

I got this as well.

I ran yarn install --no-lockfile and it worked, so I deleted the node modules again and deleted yarn.lock. It looks like a bug in yarn, because yarn wasn't having issues in previous versions of my application.

jfa
  • 1,047
  • 3
  • 13
  • 39
0

I had the same network retrying issue when I used yarn install, simply using yarn worked for me or increase the timeout.

Yogesh Devgun
  • 1,297
  • 1
  • 19
  • 36
0

I have tried a lot:

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

finally it works!

0

Tired reinstall/install yarn but, not works, for me the problem was with the nvm cache:

nvm cache clear

After cleaning it solved the issue.

Eduardo Ramos
  • 496
  • 4
  • 12
0

I had this timeout issue and the problem for me was that the image was built from an M2 MacBook. The fix was to add the --platform linux/amd64 param to the docker build command: docker build --platform linux/amd64

Luci Furtun
  • 169
  • 1
  • 5
0

Had the same issue in Ubuntu, the solution was to disable IPv6 from network settings but also to edit the etc/hosts file, as mentioned in this Reddit post. I went with the former.

Andrés Fernández
  • 3,045
  • 2
  • 19
  • 21