I ran into the likelihood of the exact same problem as you.
I switched from 4.2.3 LTS to 5.9, and all npm functions stopped, always generating this error.
I needed to do the following:
- Remove Node
- Save anything in the Node installation folder that you can save
- Completely remove the Node installation
- Reinstall 5.9
After that, everything was cool. I cleared the folder after I noticed that the old installer 4.2.3 was installed in the Installer directory. I did not know what it was, but better safe than sorry.
source share