I had this too, after running brew install yarn
yesterday. At least, everything was fine up until then.
I ran rm -rf node_modules
and tried to reinstall, but no npm
command was working.
In the end I took the rather simple step of reinstalling Node via the official Node installer for Mac OS X.
https://nodejs.org/en/download/
Everything is fine now. Just went back to the directory, ran npm install
and it's done the trick.