You may have to install a more recent version of IPFS. I'd suggest:
# Install Node Version Manager (nvm) if you don't have it
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Install and use a newer Node version (LTS)
nvm install 22
nvm use 22
Try clearing rpm cache again but more thoroughly this time:
# Force clear the cache
npm cache clean --force
# Delete the cache folder manually
rm -rf ~/.npm
Check if you have sufficient permission:
# Make sure you own your npm directories
sudo chown -R $USER:$USER ~/.npm
sudo chown -R $USER:$USER ~/.config
Try installing with some additional flags:
npm install ipfs --save --legacy-peer-deps --unsafe-perm=true
If you still have the same issues, you may try using yarn instead:
# Install yarn
npm install -g yarn
# Install IPFS using yarn
yarn add ipfs
If none of the above solutions work, try installing a new directory with a fresh package.json