Correct place and name of library

Created on 14 April 2025, 13 days ago

Hello,

I'm sorry to ask this question but I can't find the right way to add the noli42/chosen in the libraries folder. Unfortunately, the README doesn't help me. I installed the module via Composer and added the the library but am getting this message:

The library could not be detected. You need to download the Chosen JavaScript file and extract the entire contents of the archive into the libraries directory on your server."

The files from noli42 are in /libraries/chosen

I tried several other possibilities lile /libraries/noli42/chosen with no success. Also, the desribed way using the composer.json repositories section didn't work (probably due to the lack in my skills).

Can somebody point me into the right direction. Where should the JS file be located to be recognized by the module?

💬 Support request
Status

Active

Version

5.0

Component

Documentation

Created by

🇩🇪Germany ThuleNB

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ThuleNB
  • 🇩🇪Germany ThuleNB

    I deinstalled Chosen and deleted the library. From the README of 5.x:

    If you are using Composer to manage your site's dependencies,
    then the Chosen plugin will automatically be downloaded to `libraries/chosen`.

    When I install the Chose module I get a jquery.chosen library. It seems to me that the wrong library is being installed. It's not the noli42 library.

    Does someone has an idea what going wrong here?

  • 🇳🇱Netherlands undersound3

    @thulenb Did you followed the steps outlined here https://git.drupalcode.org/project/chosen/-/blob/5.0.1/README.md?ref_typ...?

    Perhaps some old references somewhere to the jquery version?

  • 🇩🇪Germany ThuleNB

    Well, I think I followed it. In my understanding it is described that there are several ways to install Chosen.
    I used Composer to install the module and the library should be installed automatically. I can see that there's a library installed (jquery.chosen) but it seems to be not the correct one. As I understand from the Chosen module's description page, version 5.x doesn't need jquery.

    So what is the correct way to install Chosen? Do I need additionally need to install the library with a repository entry?

    Installation with repository entry:
    Add the following entry in the "repositories" section of your main composer.json file.

    {
        "type": "package",
        "package": {
            "name": "noli42/chosen",
            "version": "3.0.0",
            "type": "drupal-library",
            "dist": {
                "url": "https://github.com/noli42/chosen/releases/download/3.0.0/chosen-assets-v3.0.0.zip",
                "type": "zip"
            }
        }
    },

    Now you can run the following command to install chosen in the right folder:

    composer require noli42/chosen:3.0.0

  • 🇩🇪Germany ThuleNB

    I'd like to try it with the repository entry but I am not sure how exactly the code needs to be added:

        "repositories": {
            "drupal": {
                "type": "composer",
                "url": "https://packages.drupal.org/8"
            },
            "0": {
                "type": "composer",
                "url": "https://packages.drupal.org/8"
            },     
            {
                "type": "package",
                "package": {
                "name": "noli42/chosen",
                "version": "3.0.0",
                "type": "drupal-library",
                "dist": {
                  "url": "https://github.com/noli42/chosen/releases/download/3.0.0/chosen-assets-v3.0.0.zip",
                  "type": "zip"
                 }
            }
        },
    },

    This is how I try but I am getting parse errors when running composer. How exactly needs this to be added?

  • 🇩🇪Germany ThuleNB

    I finally got it.
    Installation with repository entry is mandatory.

    What was confusing me in the README:

    Download the Chosen js plugin (https://github.com/noli42/chosen) and extract the file under "libraries".
    Download and enable the module.
    Configure at Administer > Configuration > User interface > Chosen (requires administer site configuration permission)

    For me, the seemed to be all I need to do. Manually adding the chosen library didn't work. I needed to add it via repositoty entry.

    Just in case someone else faces this problem.

  • 🇭🇺Hungary nagy.balint

    Hello!

    I am glad that you have managed to solve the issue.

    Technically the repository entry also takes the release from https://github.com/noli42/chosen/releases/tag/3.0.0 but we can likely improve the README of course.

    Any suggestion for improving the README is welcome.

Production build 0.71.5 2024