透過 Azure Devops 管道將 Typescript + Angular 應用程式部署到 Azure 應用程式服務(找不到 ng 模組)

透過 Azure Devops 管道將 Typescript + Angular 應用程式部署到 Azure 應用程式服務(找不到 ng 模組)

得到了這個打字稿+角度應用程序,在本地運行得很好。

嘗試在 Azure Devops 上設定部署管道,建置並發佈到應用程式服務(linux nodejs webapp)。

管道工作正常,整個管道成功 - 建置和發布階段。

但是,我無法讓已部署的應用程式正常工作 - 當它嘗試“npm start”時,它出現“ng module not found”錯誤。就是這樣。

我究竟做錯了什麼?怎麼修?

這是 yaml:

    # Node.js Express Web App to Linux on Azure
# Build a Node.js Express app and deploy it to Azure as a Linux web app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger: none

variables:

  # Azure Resource Manager connection created during pipeline creation
  azureSubscription: 'redacted'

  # Web app name
  webAppName: 'redacted'

  # Environment name
  environmentName: 'redacted'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build stage
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '14.x'
      displayName: 'Install Node.js'

    - script: |
        npm i -g -force @angular/[email protected]
        npm i -force
        ng build --prod
      displayName: 'npm install etc'

    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(environmentName)
    pool:
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:
          steps:
          - task: AzureWebApp@1
            displayName: 'Azure Web App Deploy: Redacted'
            inputs:
              azureSubscription: $(azureSubscription)
              appType: webAppLinux
              appName: $(webAppName)
              runtimeStack: 'NODE|14.x'
              package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
              startUpCommand: 'npm start'

乾杯,

相關內容