cache: improve cache clear error message · npm/cli@043da23 (original) (raw)

Original file line number Diff line number Diff line change
@@ -56,14 +56,20 @@ const clean = async (args) => {
56 56 }
57 57 const cachePath = path.join(npm.cache, '_cacache')
58 58 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.`)
67 73 }
68 74 return rimraf(cachePath)
69 75 }