LIB002 "cdnjs" 提供者無法解析 "jquery@3.6.1" 程式庫_Libraries could not be resolved by the "cdnjs" provider

 
若接獲有人給的visual studio專案
如出現此錯誤訊息
LIB002 "cdnjs" 提供者無法解析 "jquery@3.6.1" 程式庫
LIB002 "cdnjs" 提供者無法解析 "twitter-bootstrap@5.2.2" 程式庫
LIB002 "cdnjs" 提供者無法解析 "font-awesome@6.2.0" 程式庫

....

LIB002 "cdnjs" 提供者無法解析 "XXXXXX" 程式庫


不外乎就是缺乏這些前端套件
有經驗的開發者 我們都知道libman主要就是一套前端庫管控的工具



基本上可切至套件管理器主控台中
下command
先確認libman cli可運行正常



查看已安裝的CLI 版本
libman --version




若要查看詳細幫助可輸入
libman --help

libman help說明

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Usage: libman [options] [command]

Options:
  --help|-h  Show help information
  --version  Show version information

Commands:
  cache      列出或清除 libman 快取內容
  clean      從專案刪除 libman.json 中定義的所有程式庫檔案
  config     取得或進行組態設定
  init       建立新的 libman.json
  install    將程式庫定義新增到 LibMan.json 檔案,並將程式庫下載到指定的位置
  restore    從提供者下載所有檔案,並將其儲存到指定的目的地
  uninstall  從指定的目的地刪除指定程式庫的所有檔案,然後從 libman.json 移除指定的程式庫定義
  update     更新指定的程式庫

Use "libman [command] --help" for more information about a command.

不過在套件管理主控台 中文內容 這裡會出現亂碼

比較正確的操作位置是在
終端機來下




restore    從提供者下載所有檔案,並將其儲存到指定的目的地
其中這套指令可幫我門自動補回遺失的library

還原在libman.json 中定義的庫文件
(記得要在libman.json存在的相對目錄下喔!! 不然會告知找不到libman.json)




另外若出現類似
Libraries could not be resolved by the "cdnjs" provider
等異常

方法1.(實際測試還是不行)
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
libman cache clean
libman install


方法2.(實際測試還是不行)
開啟csproj
將<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.161" />

改為<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
在重新下指令


方法3.重新下載在拉到對應目錄或更換CDN提供服務商




Ref:
https://dotblogs.com.tw/Im_sqz777/2020/09/03/222746
https://blog.darkthread.net/blog/libman-in-vs2017/
https://www.bookstack.cn/read/asp/744351ff278a251c.md
https://github.com/aspnet/LibraryManager/issues/685
https://csharp.christiannagel.com/2018/08/22/librarymanager-2/
https://blog.csdn.net/qq_34383510/article/details/125104038
https://social.msdn.microsoft.com/Forums/zh-TW/f1ffa3d3-39ec-4979-9455-1ef13298529f/visual-studioaddclientlibrarycdnjsunpkgjsdelivr?forum=236
https://developercommunity.visualstudio.com/t/libman-cant-resolve-package/513725





留言

這個網誌中的熱門文章

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header

經得起原始碼資安弱點掃描的程式設計習慣培養(三)_7.Cross Site Scripting(XSS)_Stored XSS_Reflected XSS All Clients

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題