I installed node using homebrew (Mojave), afterwards php stoped working and if I try to run php -v I get this error:
php -v
php -v dyld: Library not lo
This is what finally worked for me.
brew reinstall postgres
After running the above command you might need to run
brew postgresql-upgrade-database
to access your previous data.