I am looking at the cache docs: https://docs.npmjs.com/cli/cache
if I ran this:
npm cache add [email protected]
how can I check later, if this is in the npm cache?
I don't see npm cache get [email protected]
in the docs...
Run: “npm cache verify” for npm version 5 and up 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.
To clear a cache in npm, we need to run the npm cache clean --force command in our terminal. To clear the cache present in npm, you need to run the command. If it doesn't work, run the force clean method since the cache is not cleared simply.
Tarball is a compressed file format. You need to unpack it before running the npm command. From: http://www.rebol.com/docs/unpack-tar-gz.html. To unpack a tar.gz file, you can use the tar command from the shell.
The npm cache is strictly a cache: it should not be relied upon as a persistent and reliable data store for package data. npm makes no guarantee that a previously-cached piece of data will be available later, and will automatically delete corrupted contents.
Looks like npm
has not a direct way to achieve this, but this script does the trick
create a file cache.js
and paste code below
const cacache = require('cacache/en')
const cachePath = require('os').homedir()+'/.npm/_cacache'
cacache.ls(cachePath)
.then((packages) => {
for(const i in packages) {
console.log(packages[i].key)
}
})
run
npm install cacache
then run
node cache.js | grep lodash
personal opinion: yarn
is designed to cache npm packages, if you are going to do that, you could give it a chance
EDIT: I made a script that does all of the above, every feedback is welcome
https://www.npmjs.com/package/npm-check-cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With