The problem for me was upgrading my global version of npm while on an incompatible version of Node (8.16.1).
I tried to uninstall npm globally but that also didn’t work because I could not use the npm command.
To fix it, I used nvm to switch to a compatible version of Node (nvm use 14.0.0
– this can be any version of Node compatible with the npm version you have installed globally). This allowed me to run npm commands so I ran npm uninstall -g npm
first of all to remove my global version of npm and then nvm uninstall 8.16.1
to remove my faulty Node version.
May need to deactivate first: nvm deactivate
https://stackoverflow.com/a/38776277/15435022
I was then able to reinstall Node 8.16.1 (nvm install 8.16.1
), and with it came a fresh install of a compatible npm version.