From 9847c82a8528cfdf5968e9bb00abd8ed47903b5c Mon Sep 17 00:00:00 2001 From: Christopher Patty Date: Thu, 8 Mar 2018 14:14:00 -0700 Subject: [PATCH] error-message: more detailed message for inaccessible files. (#18384) PR-URL: https://github.com/npm/npm/pull/18384 Credit: @chrisjpatty Reviewed-By: @zkat --- lib/utils/error-message.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index b756900ccbe..cd31d7d7144 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -23,8 +23,17 @@ function errorMessage (er) { case 'EACCES': case 'EPERM': short.push(['', er]) - detail.push(['', ['\nPlease try running this command again as root/Administrator.' - ].join('\n')]) + detail.push([ + '', + [ + '\nThe operation was rejected by your operating system.', + (process.platform === 'win32' + ? 'It\'s possible that the file was already in use (by a text editor or antivirus),\nor that you lack permissions to access it.' + : 'It is likely you do not have the permissions to access this file as the current user'), + '\nIf you believe this might be a permissions issue, please double-check the', + 'permissions of the file and its containing directories, or try running', + 'the command again as root/Administrator (though this is not recommended).' + ].join('\n')]) break case 'ELIFECYCLE':