Doing a chmod 777
is a fairly radical solution. Try these first, one at a time, and stop when one works:
$ sudo chmod -R 777 /usr/local/lib/node_modules/npm
$ sudo chmod -R 777 /usr/local/lib/node_modules
$ sudo chmod g+w /usr/local/lib
$ sudo chmod g+rwx /usr/local/lib
$ brew postinstall node
is the only install part where I would get a problem
Permission denied - /usr/local/lib/node_modules/npm/.github
So I
// !! READ EDIT ABOVE BEFORE RUNNING THIS CODE !!
$ sudo chmod -R 777 /usr/local/lib
$ brew postinstall node
and viola, npm is now linked
$ npm -v
3.10.10
Extra
If you used -R 777
on lib my recommendation would be to set nested files and directories to a default setting:
find /usr/local/lib -type f -print -exec chmod 644 {} \;
find /usr/local/lib -type d -print -exec chmod 755 {} \;
chmod /usr/local/lib 755