简体   繁体   English

使用 Azure 管道部署 Angular 应用程序,失败

[英]Deploying an Angular app with Azure Pipeline, Failed

I've built an Angular app that runs fine from localhost.我已经构建了一个 Angular 应用程序,它可以从 localhost 正常运行。 I uploaded it to a GitHub repository and I am trying to connect it to an Azure Pipeline.我将它上传到 GitHub 存储库,我正在尝试将它连接到 Azure 管道。 But it always fails on NPM Install and Build.但它在 NPM 安装和构建时总是失败。 I am new to using Azure Pipelines and think that I may be running something incorrectly.我是使用 Azure 管道的新手,我认为我可能运行不正确。 Below is the yaml that was generated for me.下面是为我生成的 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'

Deploying an Angular app with Azure Pipeline, Failed使用 Azure 管道部署 Angular 应用程序,失败

Since it works fine on your local, so the error should comes from the pipeline settings.由于它在您的本地工作正常,因此错误应该来自管道设置。

Please check if the following points that may cause errors are helpful to you:请检查以下可能导致错误的几点是否对您有帮助:

First, when you create a pipeline, you need select the Github as the source location:首先,创建管道时,需要 select 和 Github 作为源位置:

在此处输入图像描述

Second, we need specify the working folder when we build the Angular app , the working folder should be the relative path to the .yml .其次,我们需要在构建 Angular 应用程序时指定工作文件夹,工作文件夹应该是.yml的相对路径。

So, I need specify the working foler when I build the Angular app by pushd /path/to/dir :因此,当我通过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'

As test, I could build the Angular app successfully with Azure devops pipeline.作为测试,我可以使用 Azure devops 管道成功构建 Angular 应用程序。

If above not help you, please share your build error log and file directory structure on github.如果以上对您没有帮助,请在 github 上分享您的构建错误日志和文件目录结构。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Angular 2应用程序部署到Azure - Deploying Angular 2 app to Azure 手动将 Angular 应用部署到 Azure 应用服务 - Manually deploying angular app to Azure App Service 使用 Github Actions 将 Angular 应用程序部署到 Azure 失败。 找不到 package.json - Deploying angular app to Azure with Github Actions failed. package.json not found 将角度应用程序部署到Azure门户网站Web应用程序后如何解决“无法加载资源404” - How to fix “Failed to load resource 404” after deploying angular application to azure portal web app 使用 Azure Devops 将 Angular 应用程序部署到 NodeJS - Deploying Angular app to NodeJS using Azure Devops 如何为 Angular 应用程序设置 Azure Pipeline - How to set up Azure Pipeline for Angular App 如何编写 bitbucket 管道来部署我的 angular 通用应用程序? - How to write bitbucket pipeline for deploying my angular universal app? 在部署Angular 2项目时,Azure持续部署失败了Github - Azure Continuous deployment failed with Github when deploying an Angular 2 project 将 Angular 应用程序部署到 Azure Web 应用程序 Angular 9 的问题 - Issue Deploying Angular App to Azure Web Apps Angular 9 在 Azure Web 应用服务中部署 Angular 通用应用 - 基于 Linux - Deploying an Angular Universal App in Azure web app service - Linux based
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM