bowerbower-install

Bower cannot find a package and fails to install new packages


So I installed via bower - jQuery UI Sortable. The package's folder was put right in my assets folder as expected. Then I wanted to install another package (for example: noty.js with bower install --save noty) and I get this:

bower noty#*                not-cached https://github.com/needim/noty.git#*
bower noty#*                   resolve https://github.com/needim/noty.git#*
bower fullcalendar#*            cached https://github.com/fullcalendar/fullcalendar.git#3.4.0
bower fullcalendar#*          validate 3.4.0 against https://github.com/fullcalendar/fullcalendar.git#*
bower noty#*                  download https://github.com/needim/noty/archive/v3.1.1.tar.gz
bower noty#*                   extract archive.tar.gz
bower noty#*                  resolved https://github.com/needim/noty.git#3.1.1
bower                        ENOTFOUND Package jQuery UI Sortable=jquery-ui-sortable not found

Note: I tried installing fullcalendar as well.

Even though it says it downloaded the package and extracted archive.tar.gz, that package is nowhere to be found in my project's folder. jQuery UI Sortable is still there. I'm even using it.

bower.json is left untouched. If I run bower install --save noty it just says:

bower noty#*                    cached https://github.com/needim/noty.git#3.1.1
bower noty#*                  validate 3.1.1 against https://github.com/needim/noty.git#*
bower                        ENOTFOUND Package jQuery UI Sortable=jquery-ui-sortable not found

I have a .bowerrc that points to resources/assets/bower (because it's a Laravel project). So how do I fix this?


Solution

  • The reason for this error is because bower uses the name to build the directory structure and define the actual name of the package. jQuery UI Sortable package defines the name using uppercase letters and spaces inside bower.json file like this:

    {
      "name": "jQuery UI Sortable",
      "version": "1.0.0",
      ...
    

    which obviously is not a so good idea, to have uppercase letters and spaces to a package directory name:

    jQuery UI Sortable

    So, we need to change the name from jQuery UI Sortable to jquery-ui-sortable and get rid of the spaces and uppercase letters. To do this, we have to define the name by using <package_installed_name>=<package_list_name>, which in our case will be:

    bower install --save jquery-ui-sortable=jquery-ui-sortable
    

    After you do this, just install noty and it should successfully install it:

    bower install noty
    

    Bower Noty install

    jQuery UI Sortable and Noty together

    Don't forget to delete the jQuery UI Sortable directory inside bower packages directory before you try to install jquery-ui-sortable with the proper name.