I have recently installed node.js from the official website via package installer on my Mac. I’ve run into an issue, though, after running
npm update -g it brokes npm. The funny thing is that node.js works. But npm show errors:
npm: command not found.
After research on github and stackoverflow issues I’ve found that on Mac it’s better idea to install nodejs via homebrew. The following steps solve this problem:
- brew uninstall node
- brew update
- brew upgrade
- brew cleanup
- brew install node
- sudo chown -R $(whoami) /usr/local (for issues with permissions)
- brew link –overwrite node
- brew postinstall node
And then everything works fine.