2017-07-19 175 views
2

所以我通过bower - jQuery UI Sortable安装。按预期方式将包的文件夹放在资产文件夹中。然后我想安装的软件包(例如:noty.jsbower install --save noty),我得到这个:Bower无法找到一个软件包并且无法安装新软件包

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 

:我尝试安装fullcalendar为好。

尽管它说它下载了软件包并解压缩了archive.tar.gz,但是该软件包无处可在我的项目文件夹中找到。 jQuery UI Sortable仍然存在。我甚至使用它。

bower.json保持不变。如果我运行bower install --save noty它只是说:

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 

我有一个.bowerrc指向resources/assets/bower(因为它是一个Laravel项目)。那么我该如何解决这个问题?

回答

2

此错误的原因是因为bower使用name来构建目录结构并定义包的实际名称。 jQuery用户界面可排序的包使用大写字母和空格定义名称里面bower.json文件是这样的:

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

这显然不是一个好主意,有大写字母和空格包的目录名称:

jQuery UI Sortable

因此,我们需要将名称从jQuery UI Sortable更改为jquery-ui-sortable并删除空格和大写字母。要做到这一点,我们必须使用<package_installed_name>=<package_list_name>,来定义它的名称在我们的情况将是:

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

执行此操作后,只需安装noty,它应能够成功安装:

bower install noty 

Bower Noty install

jQuery UI Sortable and Noty together

不要忘记删除jQuery UI Sortable试用版内的软件包目录,然后尝试使用正确的名称安装jquery-ui-sortable