Installing an external library that is required by a contributed module

Last updated on
3 April 2022

If you want to install a contributed module, that depends on an external library, and also depends on the Libraries API module, you are on the right page.

Installing the Libraries API module and installing an external library are two separate steps and are meant to be done independently as described in the ordered steps below.

Install Libraries API

Install Libraries API just like you would any other contributed module. For detailed instruction on this see the Drupal 8 Installing Contributed Modules notes. The Libraries API module directory should be installed in one of the following directories:

  • modules
  • sites/example.com/modules (if you have a multi-site installation)

As noted earlier you should not enable the module the depends on Libraries API yet. That step will come last.

Install the external library

  1. Download the library
    The module that requires the external library should provide a link to the homepage of that library or, even better, directly to that library's download page. Sometimes the module will specify a version for you to download, otherwise, just download the latest version.
  2. Extract the files
    If the file you downloaded is an archive, i.e. its file extension is .zip or .tar.gz, you will need to extract it first. On Windows, use a program like 7-zip to extract it. On the Mac, you can the native OS archiving tools. For *nix systems, use the command line: tar -zxvf modulename-drupalversionnumber.tar.gz. After extracting the file, you should see multiple files or a single folder with the library's name.
  3. Upload the library
    Libraries API currently utilizes the following locations for library sources:
    • sites/default/files/library-definitions

    If the appropriate directory does not yet exist, simply create it. Then inside that directory create a new directory with the machine name of the library. The machine name should be provided by the module that requires it, sometimes implicitly as in "Install the foo library!" (in that case the machine name would be foo). Upload the library files into the directory you have just created. If for example, the library consists of a directory, which you have just extracted, upload the entire directory into the sites/all/assets/vendor/machine_name directory.

Install the other module

Now you should be able to install the module that requires the external library just like you installed Libraries API above, or as you would install any other contributed module.

Help improve this page

Page status: No known problems

You can: