'There appears to be trouble with the npm registry (returned undefined). Retrying

I'm trying to install dependencies in my project but when I run yarn install I get the following error

[2/5] 🔍  Resolving packages...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
info There appears to be trouble with the npm registry (returned undefined). Retrying...
⠁ [email protected]/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:66965
            throw new (_errors || _load_errors()).ResponseError(_this3.reporter.lang('requestFailed', description), res.statusCode);
            ^

ResponseError: Request failed "502 Bad Gateway"
    at ResponseError.ExtendableBuiltin (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:696:66)
    at new ResponseError (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:802:124)
    at Request.params.callback [as _callback] (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:66965:19)
    at Request.self.callback (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:140749:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:141721:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:141643:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22) {
  responseCode: 502
}

I tried

  1. to remove yarn.lock file and run yarn install again
  2. to increase network timeout yarn install --network-timeout 100000

Still getting the same error



Solution 1:[1]

this worked for me:

Delete any "*.lock" and rm node_modules. Or rm -rf node_modules/

Clean a flush all connections things like DNS, caches and so on.

Terminal commands:

 set http_proxy=

 set https_proxy=

 yarn config delete proxy

 npm config rm https-proxy

 npm config rm proxy

npm config set registry "http://registry.npmjs.org" or npm config set registry "https://registry.npmjs.org"

Restart your terminal and Try.

Use : yarn add mypckge --network-timeout 100000 or yarn --network-timeout 100000

but first try just yarn

Restart your terminal and Try yarn again and/or with --network-timeout.

link to MichelDiz answer

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vga