I just came back to work on a React project after working in the Rails environment and found that I cannot run any NPM commands in my Mac terminal. I\'ve tried all the remedies
One other suggestion after trying these that finally worked for me was simply upgrading my node by downloading the latest via the download and package installer from here:
https://nodejs.org/en/download/
Before doing this trying to run any npm command gave me the same error brought in OP's question
npm commands started working for me after that.