Magento 2 bin/magento Missing

You may face an issue like when you run any command from the SSH it does not work and all CLI commands stop working due to bin/magento being missing

The Magento file of /bin directory may remove after you do Magento version upgrade, but don’t worry you can follow the below steps and bin/magento will generate automatically and you can run all CLI commands again without any issue.

Steps to regenerate bin/magento in Magento 2

Step 1: Remove the magento2-base module by running the below command.

//run below from magento root directory.
rm -rf vendor/magento/magento2-base vendor/magento/magento2-ee-base

Step 2: Then run the below commands to re-create the magento2-base directory and bin/magento.

composer clear-cache
composer install

After following above steps you can see that bin/magento file is at their place and now you can run any cli-commands without any issue 🙂