2017-07-19 173 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