Google shows this gist at the top of most searches GitHub https://gist.github.com/DanHerbert/9520689 which is unfortunately very old and doesn't work now.
After doing an upgrade with homebrew, we got this error:
module.js:457
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
Most of the node/npm forums say this means npm is really dead, and to start again.
The stastackoverflow below gave us a clue to fixing this, the issue is that if you fully remove node with brew, even with the --force, it still leaves the /usr/local/lib/node_modules directory in place so upgrades get hosed.
This seems to more evident in Mac OS Sierra.
brew uninstall --force node
rm -rf /usr/local/lib/node_modules
rm /usr/local/bin/npm
brew install node