Skip to content

Commit

Permalink
cache: improve cache clear error message
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Oct 20, 2020
1 parent a57f5c4 commit 043da23
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,20 @@ const clean = async (args) => {
}
const cachePath = path.join(npm.cache, '_cacache')
if (!npm.flatOptions.force) {
throw new Error('As of npm@5, the npm cache self-heals from corruption ' +
'issues and data extracted from the cache is guaranteed to be valid. ' +
'If you want to make sure everything is consistent, use `npm cache ' +
'verify` instead. On the other hand, if you\'re debugging an issue ' +
'with the installer, you can use `npm install --cache /tmp/empty-cache` ' +
'to use a temporary cache instead of nuking the actual one.\n\n' +
'If you\'re sure you want to delete the entire cache, rerun this ' +
'command with --force.')
throw new Error(`As of npm@5, the npm cache self-heals from corruption issues
by treating integrity mismatches as cache misses. As a result,
data extracted from the cache is guaranteed to be valid. If you
want to make sure everything is consistent, use \`npm cache verify\`
instead. Deleting the cache can only make npm go slower, and is
not likely to correct any problems you may be encountering!
On the other hand, if you're debugging an issue with the installer,
or race conditions that depend on the timing of writing to an empty
cache, you can use \`npm install --cache /tmp/empty-cache\` to use a
temporary cache instead of nuking the actual one.
If you're sure you want to delete the entire cache, rerun this command
with --force.`)
}
return rimraf(cachePath)
}
Expand Down

0 comments on commit 043da23

Please sign in to comment.