diff --git a/__tests__/fixtures/request-cache/GET/localhost/.bin b/__tests__/fixtures/request-cache/GET/localhost/.bin index 9970987dd5..93408c1335 100644 --- a/__tests__/fixtures/request-cache/GET/localhost/.bin +++ b/__tests__/fixtures/request-cache/GET/localhost/.bin @@ -1,5 +1,5 @@ HTTP/1.1 200 OK -Date: Wed, 19 Oct 2016 13:30:48 GMT +Date: Mon, 24 Oct 2016 13:03:20 GMT Connection: close Content-Length: 2 diff --git a/src/reporters/lang/en.js b/src/reporters/lang/en.js index c392c0717d..b11fca5b60 100644 --- a/src/reporters/lang/en.js +++ b/src/reporters/lang/en.js @@ -199,6 +199,7 @@ const messages = { publishing: 'Publishing', infoFail: 'Received invalid response from npm.', + malformedRegistryResponse: 'Received malformed response from registry. The registry may be down.', }; export type LanguageKeys = $Keys; diff --git a/src/resolvers/registries/npm-resolver.js b/src/resolvers/registries/npm-resolver.js index f01059b2e3..6b2809518f 100644 --- a/src/resolvers/registries/npm-resolver.js +++ b/src/resolvers/registries/npm-resolver.js @@ -24,6 +24,10 @@ export default class NpmResolver extends RegistryResolver { static registry = 'npm'; static async findVersionInRegistryResponse(config: Config, range: string, body: RegistryResponse): Promise { + if (!body['dist-tags']) { + throw new MessageError(config.reporter.lang('malformedRegistryResponse')); + } + if (range in body['dist-tags']) { range = body['dist-tags'][range]; }