Drupal - How to install with composer external library that drupal module depends on

You should be able to include this package via composer by adding some repository info.

Add a package definition to your repositories section in your composer.json. The resulting repositories section may look like this:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    {
        "type": "package",
        "package": {
            "name": "usrz/bootstrap-languages",
            "type": "drupal-library",
            "version": "dev-master",
            "dist": {
                "url": "https://github.com/usrz/bootstrap-languages/archive/master.zip",
                "type": "zip"
            }
        }
    }
]

Then you can just use composer require like:

composer require usrz/bootstrap-languages

This will add a new line to your require section in composer.json like

"usrz/bootstrap-languages": "dev-master"

Normally I would try to use this approach with a release tag of a package, rather than the master branch, but no tag exists for this repository.


You can do this by using Asset Packagist. Add repository and installer-types, installer-paths to your composer.json

"repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
],
"extra": {
    "installer-types": ["bower-asset", "npm-asset"],
    "installer-paths": {
        "docroot/libraries/{$name}": ["type:drupal-library", "type:bower-asset", "type:npm-asset"]
    },

Then you can add package

composer require bower-asset/bootstrap-language