How do I convert a pre-existing site to a Composer-managed application? The latest Drush 9.x version recommends that Drupal 8 sites will be built using Composer, with Drush listed as a dependency. However, when you install Composer and Drush globally per step #1 on http://docs.drush.org/en/master/install and then proceed to step #2 Installing Drush Launcher and then try to run Drush on a pre-existing Drupal website (e.g. drush --version), then you will get:


  Drush Launcher Version: 0.6.0
  The Drush launcher could not find a Drupal site to operate on. Please do one of the following:
  
  
  Navigate to any where within your Drupal project and try again.
  Add --root=/path/to/drupal so Drush knows where your site is located.
  


How do I get around this problem, and make Drush work with pre-existing Drupal sites?
Follow
https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies#managing-existing-site
Copy-paste method:  


Install Composerize Drupal with composer global require grasmash/composerize-drupal command;   
Run cd path/to/drupal/project/repo &amp;&amp; composer composerize-drupal
--composer-root=[repo-root]    --drupal-root=[drupal-root] where [composer-root] is the root directory of your project where .git is located and    [drupal-root] is the Drupal root where index.php is located.

Manually restructure pre-existing Drupal projects per discussion between Norman and Moshe on https://github.com/drush-ops/drush-launcher/issues/33
Rebuild the code base from scratch, see https://www.jeffgeerling.com/blog/2018/converting-non-composer-drupal-codebase-use-composer