When an install fails in a strange way, deleting the whole cache is the reflex. There is a gentler step I would try first.
npm cache verify
It goes through the cache folder, checks that the stored data and the index are intact, and garbage collects whatever is no longer needed. At the end it reports how much content it verified and how many index entries there are. Your good downloads stay, so the next install does not have to fetch everything again.
To see where the cache lives:
npm config get cache
The full wipe is npm cache clean --force. npm’s own documentation says that is typically unnecessary, because the cache heals itself and is resistant to corruption. The --force is there to make you think twice.
So if an install still fails after a verify, I would look elsewhere: the lock file, the registry address, your proxy, the Node version. A verify can take a while on a large cache. It also only concerns the download cache, not the node_modules folder inside your project.
Further reading: npm docs: npm cache
Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it