Skip to content

Commit 043da23

Browse files
committed
cache: improve cache clear error message
1 parent a57f5c4 commit 043da23

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/cache.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,20 @@ const clean = async (args) => {
5656
}
5757
const cachePath = path.join(npm.cache, '_cacache')
5858
if (!npm.flatOptions.force) {
59-
throw new Error('As of npm@5, the npm cache self-heals from corruption ' +
60-
'issues and data extracted from the cache is guaranteed to be valid. ' +
61-
'If you want to make sure everything is consistent, use `npm cache ' +
62-
'verify` instead. On the other hand, if you\'re debugging an issue ' +
63-
'with the installer, you can use `npm install --cache /tmp/empty-cache` ' +
64-
'to use a temporary cache instead of nuking the actual one.\n\n' +
65-
'If you\'re sure you want to delete the entire cache, rerun this ' +
66-
'command with --force.')
59+
throw new Error(`As of npm@5, the npm cache self-heals from corruption issues
60+
by treating integrity mismatches as cache misses. As a result,
61+
data extracted from the cache is guaranteed to be valid. If you
62+
want to make sure everything is consistent, use \`npm cache verify\`
63+
instead. Deleting the cache can only make npm go slower, and is
64+
not likely to correct any problems you may be encountering!
65+
66+
On the other hand, if you're debugging an issue with the installer,
67+
or race conditions that depend on the timing of writing to an empty
68+
cache, you can use \`npm install --cache /tmp/empty-cache\` to use a
69+
temporary cache instead of nuking the actual one.
70+
71+
If you're sure you want to delete the entire cache, rerun this command
72+
with --force.`)
6773
}
6874
return rimraf(cachePath)
6975
}

0 commit comments

Comments
 (0)