報錯信息

Done in 14s using pnpm v10.16.1
> jg-inms-application-app@develop develop
> vite build --mode develop
[36mvite v5.4.21 [32mbuilding for develop...[36m[39m
<script src="./config/basic.js"> in "/index.html" can't be bundled without type="module" attribute
  transforming...
  [unplugin-vue-components] component "IndexRange"(/data/.jenkins/workspace/jg-inms-application-web/src/components/MyDateTime/indexRange.vue) has naming conflicts with other components, ignored.
  [unplugin-vue-components] component "Index copy"(/data/.jenkins/workspace/jg-inms-application-web/src/components/MyTerminal/index copy.vue) has naming conflicts with other components, ignored.
  [32m✓[39m 634 modules transformed.
  [31mx[39m Build failed in 5.34s
  [31merror during build:
  [31m[vite:load-fallback] Could not load /data/.jenkins/workspace/jg-inms-application-web/src/components/MyUpload/index.vue (imported by src/plugins/components.js): ENOENT: no such file or directory, open '/data/.jenkins/workspace/jg-inms-application-web/src/components/MyUpload/index.vue'[31m
  at async open (node:internal/fs/promises:639:25)
  at async Object.readFile (node:internal/fs/promises:1246:14)
  at async Object.load (file:///data/.jenkins/workspace/jg-inms-application-web/node_modules/.pnpm/vite@5.4.21_@types+node@24.9.2_sass@1.65.1_terser@5.44.0/node_modules/vite/dist/node/chunks/dep-BK3b2jBa.js:65357:25)
  at async PluginDriver.hookFirstAndGetPlugin (file:///data/.jenkins/workspace/jg-inms-application-web/node_modules/.pnpm/rollup@4.52.5/node_modules/rollup/dist/es/shared/node-entry.js:22308:28)
  at async file:///data/.jenkins/workspace/jg-inms-application-web/node_modules/.pnpm/rollup@4.52.5/node_modules/rollup/dist/es/shared/node-entry.js:21308:33
  at async Queue.work (file:///data/.jenkins/workspace/jg-inms-application-web/node_modules/.pnpm/rollup@4.52.5/node_modules/rollup/dist/es/shared/node-entry.js:22536:32)[39m
  find: ‘/data/.jenkins/workspace/jg-inms-application-web/dist/’: 沒有那個文件或目錄
  找出路徑==>
  開始壓縮
  /usr/bin/jenkins-web-package.sh: 第 58 行:cd: /data/.jenkins/workspace/jg-inms-application-web/dist: 沒有那個文件或目錄
  zip warning: name not matched: develop
  zip error: Nothing to do! (try: zip -r develop.zip . -i develop)
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (遠程部署)
  [Pipeline] sshPublisher
  SSH: Connecting from host [dev-centos]
  SSH: Connecting with configuration [192.168.100.90] ...
  SSH: Creating session: username [root], hostname [192.168.100.90], port [22]
  SSH: Connecting session ...
  SSH: Connected
  SSH: Opening SFTP channel ...
  SSH: SFTP channel open
  SSH: Connecting SFTP channel ...
  SSH: Connected
  SSH: cd [/]
  SSH: OK
  SSH: Opening exec channel ...
  SSH: EXEC: channel open
  SSH: EXEC: STDOUT/STDERR from command [bash /usr/bin/jenkins-web-deploy.sh jg-inms-application-web develop jg-inms-application-web] ...
  SSH: EXEC: connected
  開始解壓縮
  unzip:  cannot find or open /data/java-project/jg-inms-application-web/develop.zip, /data/java-project/jg-inms-application-web/develop.zip.zip or /data/java-project/jg-inms-application-web/develop.zip.ZIP.
  mv: 無法獲取'/usr/local/nginx/html/web/develop/jg-inms-application-web/develop/*' 的文件狀態(stat): 沒有那個文件或目錄
  SSH: EXEC: completed after 200 ms
  SSH: Disconnecting configuration [192.168.100.90] ...
  ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [1]]
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  Finished: UNSTABLE

原因: /components/MyUpload/index.vue文件引入大小寫問題;


看到Jenkins部署Vue3項目失敗了。從日誌來看,問題鏈條比較清晰:Vite構建失敗導致沒有生成dist目錄,進而導致後續的壓縮和部署步驟失敗。下面我幫你梳理一下問題和解決方案。

為了讓你能快速把握核心疑問和應對方案,我先用一個表格來彙總主要的錯誤點、原因和解決方向:

錯誤階段

關鍵錯誤信息/現象

可能原因/解決方案

Vite構建

Could not load .../MyUpload/index.vue: ENOENT

1. 文件缺失:確認MyUpload/index.vue文件是否存在。

2. 大小寫敏感:檢查文件名/路徑大小寫是否正確。

Vite構建

component "IndexRange" ... has naming conflicts

組件命名衝突:檢查方案中是否有重複註冊的同名組件。

後續步驟

沒有那個文件或目錄, Nothing to do!

構建失敗連鎖反應:Vite構建失敗未生成dist目錄,導致後續步驟(壓縮、部署)失敗。此問題會在Vite構建成功後自動解決。

1. 解決Vite構建失敗(核心)

構建失敗是當前所有問題的根源,主要需要解決兩個錯誤。

  • 修復檔案路徑錯誤
    日誌顯示無法加載 /src/components/MyUpload/index.vue 文件。Linux系統對文件路徑大小寫敏感,這和Windows/macOS不同。請按以下步驟排查:
  • 確認文件存在:在Jenkins工作空間中,檢查文件 /src/components/MyUpload/index.vue 是否存在。
  • 檢查路徑和文件名大小寫:確認路徑中每一個字母的大小寫都與代碼中的import語句完全匹配。例如,myuploadMyuploadMyUpload 會被視為不同的文件。
  • 處理組件命名衝突
    日誌中出現了組件命名衝突的警告。這即使可能不會直接導致構建失敗,但最好予以應對。
  • 檢查 src/plugins/components.js 以及其他你註冊了全局組件的地方,確保沒有重複註冊相同名稱的組件。
  • 重點關注衝突的組件:IndexRangeIndex copy
2. 修復HTML中的腳本引用

日誌中有一行提示:<script src="./config/basic.js"> in "/index.html" can't be bundled without type="module" attribute

  • 對於在 index.html 中直接引用的、不需要Vite處理的傳統全局腳本,可以<script>標籤上添加 type="module" 屬性,或者更常見的做法是添加 rel="modulepreload"
3. 優化Jenkins流程與安裝

通過在解決完構建障礙後,能夠考慮優化Jenkins流程,避免類似問題。

  • 構建失敗應提前終止繼續執行無意義的後續步驟。就是:目前的流程是即使Vite構建失敗了,依然試圖執行後續的壓縮和部署步驟。你可以在Jenkins Pipeline中調整,當構建階段失敗時,直接退出整個Pipeline,標記構建為失敗,而不
  1. 首要任務:登錄Jenkins服務器,進入本次構建的工作空間目錄,仔細檢查並修復 /src/components/MyUpload/index.vue記錄路徑和大小寫問題。這是最可能導致構建失敗的環節。
  2. 次要清理:解決 index.html 中的腳本引用問題和組件命名衝突警告。
  3. 流程優化構建失敗,則讓Jenkins Pipeline直接終止,避免執行後續步驟。就是:在Vite構建步驟後,增加邏輯判斷。若

希望這些步驟能幫助你快速定位並解決問題。如果排查了文件路徑問題後依然失敗,可以告訴我更多的上下文信息,例如MyUpload組件相關的導入代碼,我們再一起分析。