If you have recently upgraded your MacOS operating system, you may get the following error in your terminal when installing some Homebrew packages:

Error: Permission denied @ apply2files - /usr/local/lib/node_modules/expo-cli/node_modules/.bin/detect-libc

How to solve the Permissions Denied problem

Simply run the following command in your terminal:

sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*

Or change the user directly:

sudo chown -R ${LOGNAME}:staff /usr/local/lib/node_modules