diff --git a/lib/audit.js b/lib/audit.js index 076ca256b7c72..492fbb214e6a1 100644 --- a/lib/audit.js +++ b/lib/audit.js @@ -189,7 +189,10 @@ function auditCmd (args, cb) { }).then((auditReport) => { return audit.submitForFullReport(auditReport) }).catch((err) => { - if (err.statusCode === 404 || err.statusCode >= 500) { + // Some 3rd Party registries such as Microsoft Azure DevOps do not presently support `npm audit`. As no token is passed for `audit` and the registry may not + // have an exception in place for audit, a 401 is returned, which informs the user of an authentication-related issue that really masks a lack of implementation. + // Therefore, the custom error message now also triggers for 401s. + if (err.statusCode === 401 || err.statusCode === 404 || err.statusCode >= 500) { const ne = new Error(`Your configured registry (${opts.registry}) does not support audit requests.`) ne.code = 'ENOAUDIT' ne.wrapped = err