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
Assume this happens on MacOS, below solution works for me.
I had an issue after upgrade my mac. I tried different solutions available on stack overflow and nothing work for me.
This solution works for me.
brew uninstall --force node
brew install node
First point remove all node versions if available.
Done. Enjoy coding.
Try this one: https://gist.github.com/DanHerbert/9520689
"If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together."
Kudos to Dan Herbert for the solution.
In my case, the solution to the problem was reinstalling the node using the official installer from https://nodejs.org (Mac OS).
Solution:
P.S. The problem appeared after yarn installation.
Remove all file from following folder
A)C:\Users\\AppData\Roaming\npm
B)C:\Users\\AppData\Roaming\npm-cache
and install node
again
then execute command "npm install -g @angular/cli
"
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.