Fatal error: Allowed memory size of x bytes exhausted (tried to allocate x bytes) in phar:///usr/local/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Check the memory_limit:

php -r "echo ini_get('memory_limit').PHP_EOL;"

Locate php.ini

php --ini

Edit php.ini

nano  /Applications/MAMP/bin/php/phpx.x.x/conf/php.ini
memory_limit = -1

Try again