From e2d377bb6419d8a3c1d80a73dba46062b4dad336 Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 17 Jul 2019 14:58:05 -0700 Subject: [PATCH] audit: report server error on failure Related: https://npm.community/t/npm-audit-fails-with-child-requires-fails-because-requires-must-be-an-object/8540 --- CHANGELOG.md | 3 +++ lib/audit.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b9af464a059e..26cdad6c76383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ Unix systems. * [`235e5d6df`](https://github.com/npm/cli/commit/235e5d6df6f427585ec58425f1f3339d08f39d8a) ensure correct owner on cached all-packages metadata ([@isaacs](https://github.com/isaacs)) +* [`fa6acd2ea`](https://github.com/npm/cli/commit/fa6acd2ea035bf26c04d7885b534d03d5b77e7ba) + [npm.community#8450](https://npm.community/t/npm-audit-fails-with-child-requires-fails-because-requires-must-be-an-object/8540) + audit: report server error on failure ([@isaacs](https://github.com/isaacs)) ### DEPENDENCIES diff --git a/lib/audit.js b/lib/audit.js index 37b54d6eca140..c86566403a2bf 100644 --- a/lib/audit.js +++ b/lib/audit.js @@ -196,7 +196,10 @@ function auditCmd (args, cb) { } else if (err.statusCode === 404) { msg = `Your configured registry (${opts.registry}) does not support audit requests.` } else { - msg = `Your configured registry (${opts.registry}) does not support audit requests, or the audit endpoint is temporarily unavailable.` + msg = `Your configured registry (${opts.registry}) may not support audit requests, or the audit endpoint may be temporarily unavailable.` + } + if (err.body.length) { + msg += '\nThe server said: ' + err.body } const ne = new Error(msg) ne.code = 'ENOAUDIT'