I\'m trying to upgrade to the latest version of node. I\'m following the instructions at http://davidwalsh.name/upgrade-nodejs
But when I do:
sudo np
In case could be useful for anyone that uses rh-*
packages this worked for me:
sudo ln -s /opt/rh/rh-nodejs8/root/usr/bin/npm /usr/local/bin/npm
For me, any of the methods mentioned above using Homebrew did not work on macOS. So, I uninstalled node using Homebrew and downloaded the node package from https://nodejs.org/en/download/ and installed it. It worked like a charm.
I had to do the following:
brew update
brew uninstall node
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
I had the same problem; here are the commands to fix it:
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
For CentOS users, this works for me:
sudo yum install npm