Install contributed modules in Drupal 10 without the official supported version

15/02/2023

With the arrival of Drupal 10, many of us are already starting to migrate to this latest version or start developing on it. Especially for a migration we may have the problem of having to port some contributed modules whose official version has not yet been migrated to Drupal 10 by the community. This had a solution when we were in the same situation but to go from Drupal 8 to 9 with this solution.

What is lenient Composer endpoint?

It is a second endpoint that Drupal.org launched to download via composer those modules that did not yet have the 'core_version_requirement' parameter implemented in their info.yml file.

The problem in Drupal 10 is that many of the modules aren't ready for Drupal 10 and therefore do not have version '10' added to this parameter. In addition, the formula described in the previous article is invalid and does not apply to perform this procedure from Drupal 9 to Drupal 10.

How to solve this problem?

The first thing we have to do is to require through composer “Lenient” so it is added to the project, we can do that by executing the command below in the terminal of our project:

composer require mglaman/composer-drupal-lenient
Installing contributed modules in Drupal 10 without the official supported version - Image 01

Once the endpoint has been added to our site, we must execute the following command to add a 'whitelist' of modules that we need to add, so then we can patch them properly using composer (link here to other drupalera post references to patch drupal via composer )

 composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/MODULE_NAME"]

Where MODULE_NAME is replaced by the actual name of the module to install.

Once this is done we can see that the following row has been added to the composer.json file:

Installing contributed modules in Drupal 10 without the official supported version - Image 02

Now, our json composer is capable to install the module we need in Drupal 10 by executing the require of the module as we normally do:

composer require drupal/barcodes
Installing contributed modules in Drupal 10 without the official supported version - Image 03

In this way we can start working with those modules that we need to work with until the official version to Drupal 10 is ready in the main drupal.org repository.