Nodejs:Resolving EACCES permissions errors when installed from .pkg

I am a super fan of installing tools if a .pkg or .dmg is available instead of using tools like homebrew or nvm. Things worked well but recently I started getting errors when I tried to update some of my other node packages specifically the below error

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

I then found some solutions here, where they mentioned reinstall of node using nvm or to change npm default directory. I then chose to go with nvm which seemed easier, but I encountered a problem, how to uninstall the existing nodejs which I installed via pkg. After a few search found this script from

sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}

with this command I was able to uninstall nodejs and then I followed the steps here to install nvm and then

nvm install node

and thats it, I am back into business 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *