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
Problem: You do not have permission to write to the directories that npm uses to store global packages and commands.
Solution: Allow permission for npm.
Open a terminal:
command + spacebar then type 'terminal'
Enter this command:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
This solution allows permission to ONLY the directories needed, keeping the other directories nice and safe.