How to Apply Patches in Drupal 8 & 9 with Composer

Apply patches in Drupal 8/9 with composer-patches plugin, then specifying URL of patch file (typically from in composer.json
  1. Install Composer
  2. Install Drupal and desired modules using Composer guide composer create-project drupal/recommended-project
  3. Install relevant modules, for example composer require drupal/yearonly
  4. Install Cameron Eagans patches plugin using composer require cweagans/composer-patches
  5. Edit composer.json extra section and add in the the patches section immediately after "installer-paths" as below, using the URL of the patch file [from]:
        "drupal/yearonly": {
          "Token types missing name property": ""
    "enable-patching": true,
  6. Run composer update to apply patches - Composer will delete the modules to be patched, then re-download them with patches applied.
  7. Add more patches to composer.json as required. You can remove these entries if the module is released with an official patch


There's a detailed guide on installing patches to Drupal 8 with Composer, but has a crucial missing step at