I faced with same trouble after brew installs yarn on my MacOs Sierra 10.12.6. (And the first try of installation fall after brew update self with a message " Homebrew must be run under Ruby 2.3! You're running 2.0.0. (RuntimeError)". So I re-run it.)
So I use n manager to reinstall npm.
- switch to another node version (for my case to 8.0) by "n" command with empty parameters
- or install new by "n x.x.x" where x.x.x the node version number (i need 6.9.1)
- delete working version by "n rm x.x.x" where x.x.x the node version number. use sudo if need
- install working version by "n x.x.x" where x.x.x the node version number. use sudo if need
- switch by to the working version of node. (see first step for reference)
I think the trouble can be caused that node was installed under sudo for case.