I just installed node and npm through the package on nodejs.org and whenever I try to search or install something with npm it throws the following error, unless I sudo the c
In case sudo chown -R $(whoami) ~/.npm didn't work for you, or you need a non terminal command solution.
The issue is that your user account does not have write permission to node_modules folder, so you can do the following
Open finder and press cmd + shift + g this will open go to folder with url
Write the following path /usr/local/lib/node_modules and press go
Right click on node_modules folder and choose Get Info
Scroll down to sharing & permissions section
Unlock to be able to make changes.
Press + and add your user account
Make sure that you choose Read & Write in privilege drop down
Now you should be able to install packages without sudo and permission issues should be solved