[英]Deploying an Angular app with Azure Pipeline, Failed
我已經構建了一個 Angular 應用程序,它可以從 localhost 正常運行。 我將它上傳到 GitHub 存儲庫,我正在嘗試將它連接到 Azure 管道。 但它在 NPM 安裝和構建時總是失敗。 我是使用 Azure 管道的新手,我認為我可能運行不正確。 下面是為我生成的 yaml。
# Node.js with Angular
# Build a Node.js project that uses Angular.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install -g @angular/cli
npm install
ng build --prod
displayName: 'npm install and build'
使用 Azure 管道部署 Angular 應用程序,失敗
由於它在您的本地工作正常,因此錯誤應該來自管道設置。
請檢查以下可能導致錯誤的幾點是否對您有幫助:
首先,創建管道時,需要 select 和 Github 作為源位置:
其次,我們需要在構建 Angular 應用程序時指定工作文件夾,工作文件夾應該是.yml
的相對路徑。
因此,當我通過pushd /path/to/dir
構建 Angular 應用程序時,我需要指定工作文件夾:
- script: |
npm install -g @angular/cli
npm install
pushd AngularDemo/AngularDemo/ClientApp
ng build --prod
popd
displayName: 'npm install and build'
作為測試,我可以使用 Azure devops 管道成功構建 Angular 應用程序。
如果以上對您沒有幫助,請在 github 上分享您的構建錯誤日志和文件目錄結構。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.