Yarn: Received malformed response from registry for undefined. When adding proxy to yarn config file

Created on 24 Oct 2017  路  46Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

bug

What is the current behavior?

I moved from using bower to yarn, and in my .bowerrc file I had as following:

{
    "directory": "src/main/webapp/bower_components",
    "proxy": "http://webdefence.global.blackspider.com:80",
    "https-proxy": "http://webdefence.global.blackspider.com:80"
}

And in .npmrc file I had as following :

save-prefix = ~
proprietary-attribs = false
registry = http://abc-pic:8081/nexus/content/repositories/npmjs/

So I removed these two files and I run the following commands :

yarn config set https-proxy http://webdefence.global.blackspider.com:80
yarn config set proxy http://webdefence.global.blackspider.com:80
yarn set registry http://abc-pic:8081/nexus/content/repositories/npmjs/
yarn config set proprietary-attribs false
yarn config set save-prefix ~

And then I run the following command :

yarn install --force --flat --production --modules-folder src/main/webapp/bower_components

But then I receive this error :

error Received malformed response from registry for undefined. The registry may be down.

Yarn config list

{ 'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '~',
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'http://abc-pic:8081/nexus/content/repositories/npmjs/',
  'strict-ssl': true,
  'user-agent': 'yarn/1.2.1 npm/? node/v5.1.0 win32 x64',
  'https-proxy': 'http://webdefence.global.blackspider.com:80',
  lastUpdateCheck: 1508835683941,
  'modules-folder': 'src/main/webapp/bower_components',
  'proprietary-attribs': false,
  'proproprietary-attribs': false,
  proxy: 'http://webdefence.global.blackspider.com:80' }
info npm config
{}

What is the expected behavior?

yarn install works.

Please mention your node.js, yarn and operating system version.

OS : windows 7 win32 x64
node version : 5.1.0
yarn version : 1.2.1
npm version : 3.3.12

triaged

Most helpful comment

Down again +1

All 46 comments

Could you also add the flag --verbose and get the output? Hopefully that will indicate what URL it is trying to hit when it reports this error.

It should end up making a request to something like "http://abc-pic:8081/nexus/content/repositories/npmjs/{package-name}" so you could pop that URL into your browser and also let us know what the registry sends back as a response.

@rally25rs This is what I got running the install with the flag --verbose :

[1/4] Resolving packages...
verbose 0.709 Performing "GET" request to "http://abc-pic:8081/nexus/content/repositories/npmjs/angular".
verbose 0.969 Request "http://abc-pic:8081/nexus/content/repositories/npmjs/angular" finished with status code 503.
verbose 0.979 Error: Received malformed response from registry for undefined. The registry may be down.
    at MessageError (C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:138:26)
    at C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:48854:15
    at next (native)
    at step (C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:92:30)
    at C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:110:14
    at new Promise (C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:93019:7)
    at C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:89:12
    at Function.findVersionInRegistryResponse (C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:48885:7)
    at C:\Dev\Workspace\ABC\webapps\rhweb\node\node_modules\yarn\lib\cli.js:48902:28
    at next (native)
error Received malformed response from registry for undefined. The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Opening the url http://abc-pic:8081/nexus/content/repositories/npmjs/angular in the browser I get the following :

output.log

... finished with status code 503

makes it sound like the registry (or proxy) might be throwing an error when Yarn hits it.

The code that prints that message is:

if (!body['dist-tags']) {
  throw new MessageError(config.reporter.lang('malformedRegistryResponse', body.name));
}

so whatever Yarn happens to be getting back doesn't have a dist-tags property in the response body. It's quite possible that there is some difference between Yarn and the browser making the GET request, possible a different http header or something? Not really sure...


If you want to try debugging this, you could build yarn from the source, and inside that if statement above, add a console.log(body) and see what yarn is actually getting.

@rally25rs I noticed that this behavior only occurs when I set proxy and https-proxy to http://webdefence.global.blackspider.com:80 which I used in .bowerrc

This is not a solution for your bug, but you also get an error like that if you have an illegal package name (such as an empty string " ": "1.0.0")

This also happens if you have a registry that can't be accessed (like only via VPN) but your internet provider returns a backup HTML page. 馃槂 If you want a PR let me know what you specifically want fixed.

Here is my .npmrc -
image

Here is curl -v -
image

yarn add prop-types --verbose
image

Prior to today yarn upgrade has always been flawless. It appears I've encountered this yarn registry bug or error, Shouldn't the default behavior error out to the console but move on and process everything else that is available?

+1

+1 Having this issue right now

Now is very slow without .yarnrc and yarn.lock

Getting this issue using create-react-app. Yarn 1.6

It back to normal currently :)

+1

Still down :>

Same here!

Work for me [email protected]

+1

Rooting for you guys, don't want to go back to that stone age package manager....SAPM...aka...NPM

npm is very slow too

yes npm is also downish.

so maybe not a yarn issue.

It's for sure npm issue because https://registry.npmjs.org/ is 503.
UPD: Fixed now

Working again now!

I just had a successful, create-react-app

NPM is still causing problems even though I've switched to Yarn? Interesting...

@knoxcard yarn is on top of npm.

Amazing. So many things depend on one service and there is no quick way around :/ Something is wrong definitely.
Works again, but until next malfunction I guess.

The day npm is definitely down, we are all doomed.

Down again.

Down again +1

@flewid-cd Yarn should get beneath NPM and then rise like a Phoenix.

Down again +1

Error: Received malformed response from registry for undefined. The registry may be down.

Down again...

@lednhatkhanh Up now.

Ohhh. It's down again. https://registry.yarnpkg.com/

The yarn registry is down but the it is shown as in operational state on https://status.yarnpkg.com/

+1

Down Again.

Was getting the same error for a yarn add, but I tried it again and we're golden. What is technology, even.

+1

What is your back up strategy? npm?

btw, just so people understand the issue... https://twitter.com/jamiebuilds/status/1000198463269699584

I closed this issue since it diverged from the original description quite a lot. @rally25rs feel free to create a new one to track the original issue.

This also happens if you have a registry that can't be accessed (like only via VPN) but your internet provider returns a backup HTML page. If you want a PR let me know what you specifically want fixed.

Here is my .npmrc -
image

Here is curl -v -
image

yarn add prop-types --verbose
image

@joshunger Could you please tell me how to have such a cute and lovely terminal prompt锛焀o~I like it~
37642677-b844120c-2be3-11e8-9f5c-a5423b3fdf66

Was this page helpful?
0 / 5 - 0 ratings